Skip to content

Commit

Permalink
Fall back to a default GOPATH
Browse files Browse the repository at this point in the history
This avoids the need to have GOPATH set and is in line with how Go itself
behaves, see golang/go#17262.

While at it, make the workspace directory check a bit stricter by really
checking for a directory.
  • Loading branch information
sschuberth authored and Kim Dykeman committed Sep 21, 2017
1 parent 90c943b commit c119800
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/license_finder/package_managers/go_dep.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ def self.package_management_command
private

def install_prefix
go_path = workspace_dir.exist? ? workspace_dir : Pathname(ENV['GOPATH'])
go_path = if workspace_dir.directory?
workspace_dir
else
Pathname(ENV['GOPATH'] || ENV['HOME'] + '/go')
end
go_path.join('src')
end

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/license_finder/package_managers/go_dep_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module LicenseFinder

context 'when dependencies are vendored' do
before do
allow(FileTest).to receive(:exist?).with('/fake/path/Godeps/_workspace').and_return(true)
allow(FileTest).to receive(:directory?).with('/fake/path/Godeps/_workspace').and_return(true)
end

it 'should return an array of packages' do
Expand Down

0 comments on commit c119800

Please sign in to comment.