Commit 1352de38 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

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/118077Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 2630085a
...@@ -103,6 +103,16 @@ func init() { ...@@ -103,6 +103,16 @@ func init() {
} }
} }
// There is a copy of findGOROOT, isSameDir, and isGOROOT in
// x/tools/cmd/godoc/goroot.go.
// Try to keep them in sync for now.
// findGOROOT returns the GOROOT value, using either an explicitly
// provided environment variable, a GOROOT that contains the current
// os.Executable value, or else the GOROOT that the binary was built
// with from runtime.GOROOT().
//
// There is a copy of this code in x/tools/cmd/godoc/goroot.go.
func findGOROOT() string { func findGOROOT() string {
if env := os.Getenv("GOROOT"); env != "" { if env := os.Getenv("GOROOT"); env != "" {
return filepath.Clean(env) return filepath.Clean(env)
...@@ -162,6 +172,8 @@ func isSameDir(dir1, dir2 string) bool { ...@@ -162,6 +172,8 @@ func isSameDir(dir1, dir2 string) bool {
// It does this by looking for the path/pkg/tool directory, // It does this by looking for the path/pkg/tool directory,
// which is necessary for useful operation of the cmd/go tool, // which is necessary for useful operation of the cmd/go tool,
// and is not typically present in a GOPATH. // and is not typically present in a GOPATH.
//
// There is a copy of this code in x/tools/cmd/godoc/goroot.go.
func isGOROOT(path string) bool { func isGOROOT(path string) bool {
stat, err := os.Stat(filepath.Join(path, "pkg", "tool")) stat, err := os.Stat(filepath.Join(path, "pkg", "tool"))
if err != nil { if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment