...
1env GO111MODULE=off
2env GOPATH=$WORK/gopath/src/shadow/root1${:}$WORK/gopath/src/shadow/root2
3
4# The math in root1 is not "math" because the standard math is.
5go list -f '({{.ImportPath}}) ({{.ConflictDir}})' ./shadow/root1/src/math
6stdout '^\(.*(\\|/)src(\\|/)shadow(\\|/)root1(\\|/)src(\\|/)math\) \('$GOROOT'(\\|/)?src(\\|/)math\)$'
7
8# The foo in root1 is "foo".
9go list -f '({{.ImportPath}}) ({{.ConflictDir}})' ./shadow/root1/src/foo
10stdout '^\(foo\) \(\)$'
11
12# The foo in root2 is not "foo" because the foo in root1 got there first.
13go list -f '({{.ImportPath}}) ({{.ConflictDir}})' ./shadow/root2/src/foo
14stdout '^\(.*gopath(\\|/)src(\\|/)shadow(\\|/)root2(\\|/)src(\\|/)foo\) \('$WORK'(\\|/)?gopath(\\|/)src(\\|/)shadow(\\|/)root1(\\|/)src(\\|/)foo\)$'
15
16# The error for go install should mention the conflicting directory.
17! go install -n ./shadow/root2/src/foo
18stderr 'go: no install location for '$WORK'(\\|/)?gopath(\\|/)src(\\|/)shadow(\\|/)root2(\\|/)src(\\|/)foo: hidden by '$WORK'(\\|/)?gopath(\\|/)src(\\|/)shadow(\\|/)root1(\\|/)src(\\|/)foo'
19
20-- shadow/root1/src/foo/foo.go --
21package foo
22-- shadow/root1/src/math/math.go --
23package math
24-- shadow/root2/src/foo/foo.go --
25package foo
View as plain text