diff options
| author | Bryan C. Mills <bcmills@google.com> | 2022-03-10 14:58:02 -0500 |
|---|---|---|
| committer | Bryan Mills <bcmills@google.com> | 2022-03-17 20:09:18 +0000 |
| commit | 2b0ac284cf4b81badb1c29e4fa299ea25cb9318f (patch) | |
| tree | f48585dcf695b32d412cac13a35c751d17953d8e /src/cmd/doc/pkg.go | |
| parent | c6244b59095a74b77c977d250708ba1858ae2388 (diff) | |
| download | go-2b0ac284cf4b81badb1c29e4fa299ea25cb9318f.tar.xz | |
cmd/doc: use 'go env' to identify GOROOT if it isn't otherwise known
Updates #51483.
Change-Id: I13d8e58b30639d8a5ed3c9e8b72c8bbaa6a6f1cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/391813
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/doc/pkg.go')
| -rw-r--r-- | src/cmd/doc/pkg.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/cmd/doc/pkg.go b/src/cmd/doc/pkg.go index 0266600730..49b68873b6 100644 --- a/src/cmd/doc/pkg.go +++ b/src/cmd/doc/pkg.go @@ -89,9 +89,11 @@ func (pkg *Package) prettyPath() string { // Also convert everything to slash-separated paths for uniform handling. path = filepath.Clean(filepath.ToSlash(pkg.build.Dir)) // Can we find a decent prefix? - goroot := filepath.Join(buildCtx.GOROOT, "src") - if p, ok := trim(path, filepath.ToSlash(goroot)); ok { - return p + if buildCtx.GOROOT != "" { + goroot := filepath.Join(buildCtx.GOROOT, "src") + if p, ok := trim(path, filepath.ToSlash(goroot)); ok { + return p + } } for _, gopath := range splitGopath() { if p, ok := trim(path, filepath.ToSlash(gopath)); ok { |
