mirror of
https://github.com/golang/go
synced 2024-11-17 19:54:45 -07:00
cmd/go: eliminate empty '()' when passing -mod=readonly explicitly to 'go list'
Discovered while investigating #37197. Updates #33326 Updates #34822 Change-Id: I38b136a4ee762a580a554125066b9778491295f2 Reviewed-on: https://go-review.googlesource.com/c/go/+/219237 Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
7385947825
commit
363bcd0068
@ -184,8 +184,9 @@ func Import(path string) (m module.Version, dir string, err error) {
|
||||
if !pathIsStd {
|
||||
if cfg.BuildModReason == "" {
|
||||
queryErr = fmt.Errorf("import lookup disabled by -mod=%s", cfg.BuildMod)
|
||||
} else {
|
||||
queryErr = fmt.Errorf("import lookup disabled by -mod=%s\n\t(%s)", cfg.BuildMod, cfg.BuildModReason)
|
||||
}
|
||||
queryErr = fmt.Errorf("import lookup disabled by -mod=%s\n\t(%s)", cfg.BuildMod, cfg.BuildModReason)
|
||||
}
|
||||
return module.Version{}, "", &ImportMissingError{Path: path, QueryErr: queryErr}
|
||||
}
|
||||
|
1
src/cmd/go/testdata/script/mod_readonly.txt
vendored
1
src/cmd/go/testdata/script/mod_readonly.txt
vendored
@ -7,6 +7,7 @@ go mod edit -fmt
|
||||
cp go.mod go.mod.empty
|
||||
! go list all
|
||||
stderr '^can''t load package: x.go:2:8: cannot find module providing package rsc\.io/quote: import lookup disabled by -mod=readonly'
|
||||
! stderr '\(\)' # If we don't have a reason for -mod=readonly, don't log an empty one.
|
||||
cmp go.mod go.mod.empty
|
||||
|
||||
# -mod=readonly should be set implicitly if the go.mod file is read-only
|
||||
|
Loading…
Reference in New Issue
Block a user