Skip to content

Commit 1352de3

Browse files
committed
cmd/go/internal/cfg: note the copy of this code in x/tools/cmd/godoc
Updates #23445 Change-Id: I4b09073e53b1cf04de698b711fb5fb0d08bc02df Reviewed-on: https://go-review.googlesource.com/118077 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 2630085 commit 1352de3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/cmd/go/internal/cfg/cfg.go

+12
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ func init() {
103103
}
104104
}
105105

106+
// There is a copy of findGOROOT, isSameDir, and isGOROOT in
107+
// x/tools/cmd/godoc/goroot.go.
108+
// Try to keep them in sync for now.
109+
110+
// findGOROOT returns the GOROOT value, using either an explicitly
111+
// provided environment variable, a GOROOT that contains the current
112+
// os.Executable value, or else the GOROOT that the binary was built
113+
// with from runtime.GOROOT().
114+
//
115+
// There is a copy of this code in x/tools/cmd/godoc/goroot.go.
106116
func findGOROOT() string {
107117
if env := os.Getenv("GOROOT"); env != "" {
108118
return filepath.Clean(env)
@@ -162,6 +172,8 @@ func isSameDir(dir1, dir2 string) bool {
162172
// It does this by looking for the path/pkg/tool directory,
163173
// which is necessary for useful operation of the cmd/go tool,
164174
// and is not typically present in a GOPATH.
175+
//
176+
// There is a copy of this code in x/tools/cmd/godoc/goroot.go.
165177
func isGOROOT(path string) bool {
166178
stat, err := os.Stat(filepath.Join(path, "pkg", "tool"))
167179
if err != nil {

0 commit comments

Comments
 (0)