20 lines
917 B
Diff
20 lines
917 B
Diff
Index: go/src/cmd/go/internal/load/pkg.go
|
|
===================================================================
|
|
--- go.orig/src/cmd/go/internal/load/pkg.go
|
|
+++ go/src/cmd/go/internal/load/pkg.go
|
|
@@ -912,7 +912,13 @@ func (p *Package) load(stk *ImportStack,
|
|
if GoTools[p.ImportPath] == ToTool {
|
|
// This is for 'go tool'.
|
|
// Override all the usual logic and force it into the tool directory.
|
|
- p.Internal.Target = filepath.Join(cfg.GOROOTpkg, "tool", full)
|
|
+ // If GOROOT_TARGET is set, then write to it for packaging purpose
|
|
+ gorootTarget := os.Getenv("GOROOT_TARGET")
|
|
+ if gorootTarget == "" {
|
|
+ p.Internal.Target = filepath.Join(cfg.GOROOTpkg, "tool", full)
|
|
+ } else {
|
|
+ p.Internal.Target = filepath.Join(gorootTarget, "pkg/tool", full)
|
|
+ }
|
|
}
|
|
if p.Internal.Target != "" && cfg.BuildContext.GOOS == "windows" {
|
|
p.Internal.Target += ".exe"
|