summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-05-06 09:03:28 -0600
committermo khan <mo.khan@gmail.com>2020-05-14 14:31:48 -0600
commita5a86a5a157a33612344b6228186146d8eb219fd (patch)
tree21f511046cd8035bba7e44203540d90d3042527f /lib
parent56d3456198aaea7c472763f3d2415dbcc9588c44 (diff)
Add specs for previous versions of golang
Diffstat (limited to 'lib')
-rw-r--r--lib/license/finder/ext/go_modules.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/license/finder/ext/go_modules.rb b/lib/license/finder/ext/go_modules.rb
index 5102740..defdbe4 100644
--- a/lib/license/finder/ext/go_modules.rb
+++ b/lib/license/finder/ext/go_modules.rb
@@ -9,9 +9,7 @@ module LicenseFinder
end
def current_packages
- stdout, _stderr, status = shell.execute([
- :go, :list, '-f', "'{{.Path}},{{.Version}},{{.Dir}}'", '-m', :all
- ])
+ stdout, _stderr, status = shell.execute(command_for_current_version)
return [] unless status.success?
stdout.lines.map do |line|
@@ -25,6 +23,20 @@ module LicenseFinder
private
+ def command_for_current_version
+ format = "'{{.Path}},{{.Version}},{{.Dir}}'"
+ case go_version
+ when '1.11', '1.12', '1.13'
+ [:go, :list, '-m', '-mod=vendor', '-f', format, :all]
+ else
+ [:go, :list, '-f', format, '-m', :all]
+ end
+ end
+
+ def go_version
+ `go version`.scan(/\sgo(?<version>\d\.\d{1,2})\s/)
+ end
+
def absolute_project_path
@absolute_project_path ||= Pathname(project_path).cleanpath
end