diff options
author | Bryan C. Mills <bcmills@google.com> | 2019-12-06 15:02:28 -0500 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2019-12-06 23:44:28 +0000 |
commit | 76d2f6cc6245d0e8876c29881570d218838c1068 (patch) | |
tree | 7410d007845cb489c00a0539c03d4c96144e1f0b /src/cmd/go/internal/modload/import.go | |
parent | df0ac450022076631280569e2a157f016dcdab80 (diff) | |
download | go-76d2f6cc6245d0e8876c29881570d218838c1068.tar.gz go-76d2f6cc6245d0e8876c29881570d218838c1068.zip |
cmd/go: include cfg.BuildModReason in 'import lookup disabled' errors
This location was missed in CL 204521.
Updates #33326
Updates #33848
Change-Id: I0ece6d9b37548d8abb54f79c69be5548a0428c76
Reviewed-on: https://go-review.googlesource.com/c/go/+/210341
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/import.go')
-rw-r--r-- | src/cmd/go/internal/modload/import.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/cmd/go/internal/modload/import.go b/src/cmd/go/internal/modload/import.go index 1899abbd8f..c7508d1702 100644 --- a/src/cmd/go/internal/modload/import.go +++ b/src/cmd/go/internal/modload/import.go @@ -183,13 +183,14 @@ func Import(path string) (m module.Version, dir string, err error) { // Look up module containing the package, for addition to the build list. // Goal is to determine the module, download it to dir, and return m, dir, ErrMissing. if cfg.BuildMod == "readonly" { - if pathIsStd { - // 'import lookup disabled' would be confusing for standard-library paths, - // since the user probably isn't expecting us to look up a module for - // those anyway. - return module.Version{}, "", &ImportMissingError{Path: path} + var queryErr error + if !pathIsStd { + if cfg.BuildModReason == "" { + queryErr = fmt.Errorf("import lookup disabled by -mod=%s", cfg.BuildMod) + } + queryErr = fmt.Errorf("import lookup disabled by -mod=%s\n\t(%s)", cfg.BuildMod, cfg.BuildModReason) } - return module.Version{}, "", fmt.Errorf("import lookup disabled by -mod=%s", cfg.BuildMod) + return module.Version{}, "", &ImportMissingError{Path: path, QueryErr: queryErr} } if modRoot == "" && !allowMissingModuleImports { return module.Version{}, "", &ImportMissingError{ |