diff options
author | Bryan C. Mills <bcmills@google.com> | 2022-02-16 12:33:17 -0500 |
---|---|---|
committer | Bryan Mills <bcmills@google.com> | 2022-02-16 19:10:58 +0000 |
commit | c016133c50512e9a83e7442bd7ac614fe7ca62de (patch) | |
tree | c02653686789a9592bcb8b8954adbb8591e96b76 /src/cmd/go/internal/modload/load.go | |
parent | a289e9ce7514a34cd930469322395bf0e89b59ea (diff) | |
download | go-c016133c50512e9a83e7442bd7ac614fe7ca62de.tar.gz go-c016133c50512e9a83e7442bd7ac614fe7ca62de.zip |
cmd/go/internal/modload: set errors for packages with invalid import paths
Prior to CL 339170, relative errors in module mode resulted in a
base.Fatalf from the module loader, which caused unrecoverable errors
from 'go list -e' but successfully rejected relative imports (which
were never intended to work in module mode in the first place).
After that CL, the base.Fatalf is no longer present, but some errors
that had triggered that base.Fatalf were no longer diagnosed at all:
the module loader left them for the package loader to report, and the
package loader assumed that the module loader would report them.
Since the module loader already knows that the paths are invalid,
it now reports those errors itself.
Fixes #51125
Change-Id: I70e5818cfcfeea0ac70e17274427b08a74fd7c13
Reviewed-on: https://go-review.googlesource.com/c/go/+/386176
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modload/load.go')
-rw-r--r-- | src/cmd/go/internal/modload/load.go | 18 |
1 files changed, 0 insertions, 18 deletions
diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go index a4a7cb263e..d4847efb98 100644 --- a/src/cmd/go/internal/modload/load.go +++ b/src/cmd/go/internal/modload/load.go @@ -1675,24 +1675,6 @@ func (ld *loader) preloadRootModules(ctx context.Context, rootPkgs []string) (ch // load loads an individual package. func (ld *loader) load(ctx context.Context, pkg *loadPkg) { - if strings.Contains(pkg.path, "@") { - // Leave for error during load. - return - } - if build.IsLocalImport(pkg.path) || filepath.IsAbs(pkg.path) { - // Leave for error during load. - // (Module mode does not allow local imports.) - return - } - - if search.IsMetaPackage(pkg.path) { - pkg.err = &invalidImportError{ - importPath: pkg.path, - err: fmt.Errorf("%q is not an importable package; see 'go help packages'", pkg.path), - } - return - } - var mg *ModuleGraph if ld.requirements.pruning == unpruned { var err error |