From ac39815d6464138ee84e7cd765bc43dbe1a3f4a7 Mon Sep 17 00:00:00 2001 From: linmaolin Date: Fri, 3 Jan 2025 00:27:40 +0000 Subject: [PATCH] go/packages: add GOROOT env to avoid TestTarget failure in OpenBSD 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 Change-Id: I829b77686ae24d869653365f3e44e457c76b46bb GitHub-Last-Rev: 6e1311bbf08ead40dfefbe84a11d5888deac784b GitHub-Pull-Request: golang/tools#552 Reviewed-on: https://go-review.googlesource.com/c/tools/+/637961 Reviewed-by: Dmitri Shuralyov Reviewed-by: Michael Matloob LUCI-TryBot-Result: Go LUCI --- go/packages/packages_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/packages/packages_test.go b/go/packages/packages_test.go index 1f2c681c481..fc420321c31 100644 --- a/go/packages/packages_test.go +++ b/go/packages/packages_test.go @@ -3339,7 +3339,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)