mirror of
https://github.com/golang/go.git
synced 2026-06-27 19:30:52 +00:00
cmd/go/internal/doc: walk GOROOT when not in a module
Fixes #78896 Change-Id: I38bf3c0539a57b446c5c3338bc7b11ca6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/769441 Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
820c83da80
commit
043b76a90d
2 changed files with 15 additions and 3 deletions
|
|
@ -185,10 +185,11 @@ func findCodeRoots() []Dir {
|
|||
// it would be good to avoid an extra run of modload.Init.
|
||||
if state := modload.NewLoader(); state.WillBeEnabled() {
|
||||
usingModules = state.HasModRoot()
|
||||
if usingModules && cfg.GOROOT != "" {
|
||||
|
||||
if cfg.GOROOT != "" {
|
||||
list = append(list,
|
||||
Dir{dir: filepath.Join(cfg.GOROOT, "src"), inModule: true},
|
||||
Dir{importPath: "cmd", dir: filepath.Join(cfg.GOROOT, "src", "cmd"), inModule: true})
|
||||
Dir{dir: filepath.Join(cfg.GOROOT, "src"), inModule: usingModules},
|
||||
Dir{importPath: "cmd", dir: filepath.Join(cfg.GOROOT, "src", "cmd"), inModule: usingModules})
|
||||
}
|
||||
|
||||
if !usingModules {
|
||||
|
|
|
|||
11
src/cmd/go/testdata/script/mod_doc.txt
vendored
11
src/cmd/go/testdata/script/mod_doc.txt
vendored
|
|
@ -74,6 +74,17 @@ stdout '// import "vendor/golang.org/x/crypto/cryptobyte"'
|
|||
go doc cmd/vendor/golang.org/x/mod/modfile
|
||||
stdout '// import "cmd/vendor/golang.org/x/mod/modfile"'
|
||||
|
||||
# Not in a module and not in GOPATH
|
||||
cd $WORK
|
||||
go env GOMOD
|
||||
stdout '(/dev/null|NUL)'
|
||||
|
||||
go doc encoding/json
|
||||
stdout '// import "encoding/json"'
|
||||
|
||||
go doc json
|
||||
stdout '// import "encoding/json"'
|
||||
|
||||
-- go.mod --
|
||||
module x
|
||||
require rsc.io/quote v1.5.2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue