Skip to content

Commit

Permalink
go/packages: add GOROOT env to avoid TestTarget failure in OpenBSD
Browse files Browse the repository at this point in the history
When running tests in OpenBSD if 'go' is built with -trimpath,
the TestTarget will always fail. Because when invoked without
proper environments, 'go' itself fails to find the GOROOT path.

Fixes golang/go#70891
  • Loading branch information
linsite committed Jan 3, 2025
1 parent 6d4eee4 commit 6e1311b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion go/packages/packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3363,7 +3363,7 @@ func main() {

pkgs, err := packages.Load(&packages.Config{
Mode: packages.NeedName | packages.NeedTarget,
Env: []string{"GOPATH=" + gopath, "GO111MODULE=off"},
Env: append(os.Environ(), "GOPATH=" + gopath, "GO111MODULE=off"),
}, filepath.Join(gopath, "src", "..."))
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 6e1311b

Please sign in to comment.