cmd/go: go work causes go build to error when symlinks are involved #53343
Labels
GoCommand
cmd/go
help wanted
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
`
mkdir bug
cd bug
mkdir lib1 lib2
cd lib1
go mod init bugsquash.com/lib1
ln -s ../lib2
cd ../lib2
go mod init bugsquash.com/lib2
mkdir -p internal/a
printf "package a\nfunc Foo() {}\n" > internal/a/foo.go
mkdir -p cmd/foo
printf 'package main\nimport "bugsquash.com/lib2/internal/a"\nfunc main() { a.Foo() }\n' > cmd/foo/foo.go
go build cmd/foo/foo.go # succeeds
cd ../lib1/lib2
go build cmd/foo/foo.go # succeeds
cd ../../
go work init
go work use ./lib2
cd lib1/lib2
go build cmd/foo/foo.go
fails with this message:
package command-line-arguments
cmd/foo/foo.go:2:8: use of internal package bugsquash.com/lib2/internal/a not allowed
cd ../../lib2
go build cmd/foo/foo.go # succeeds
cd ../
rm go.work
cd lib1/lib2
go build cmd/foo/foo.go # succeeds
`
What did you expect to see?
I expect go build to succeed in lib1/lib2 (lib2 is a symlink) even when using go.work. If I remove go.work it works.
What did you see instead?
package command-line-arguments cmd/foo/foo.go:2:8: use of internal package bugsquash.com/lib2/internal/a not allowed
The text was updated successfully, but these errors were encountered: