Skip to content

Commit c119800

Browse files
sschuberthKim Dykeman
authored andcommitted
Fall back to a default GOPATH
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.
1 parent 90c943b commit c119800

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/license_finder/package_managers/go_dep.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ def self.package_management_command
3636
private
3737

3838
def install_prefix
39-
go_path = workspace_dir.exist? ? workspace_dir : Pathname(ENV['GOPATH'])
39+
go_path = if workspace_dir.directory?
40+
workspace_dir
41+
else
42+
Pathname(ENV['GOPATH'] || ENV['HOME'] + '/go')
43+
end
4044
go_path.join('src')
4145
end
4246

spec/lib/license_finder/package_managers/go_dep_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module LicenseFinder
4444

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

5050
it 'should return an array of packages' do

0 commit comments

Comments
 (0)