diff options
author | Jay Conrod <jayconrod@google.com> | 2019-11-13 13:26:13 -0500 |
---|---|---|
committer | Jay Conrod <jayconrod@google.com> | 2019-11-13 23:05:47 +0000 |
commit | 608b94bef2f3e1427cfb498e7733964aba304093 (patch) | |
tree | 40c56e35e2c8a9f4ec560ef163e59fd246760d6c /src/cmd/go/internal/load/pkg.go | |
parent | 718f553915cc1c13d7b31cd264c131987f67f14d (diff) | |
download | go-608b94bef2f3e1427cfb498e7733964aba304093.tar.gz go-608b94bef2f3e1427cfb498e7733964aba304093.zip |
cmd/go: fix error for empty packages referenced with relative paths
'go build' now reports a more useful error when a relative path on the
command line points to a directory that doesn't exist or a directory
without .go files. Errors are generated by go/build.Context.ImportDir
instead of a vague call to base.Fatalf in modload.
Fixes #35414
Change-Id: I2642230c5e409107b98bb6d6c3a484d8d25b4147
Reviewed-on: https://go-review.googlesource.com/c/go/+/206902
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/load/pkg.go')
-rw-r--r-- | src/cmd/go/internal/load/pkg.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index 6a6f77e367..8fc33e35fa 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -670,6 +670,11 @@ func loadPackageData(path, parentPath, parentDir, parentRoot string, parentIsStd // we create from the full directory to the package. // Otherwise it is the usual import path. // For vendored imports, it is the expanded form. + // + // Note that when modules are enabled, local import paths are normally + // canonicalized by modload.ImportPaths before now. However, if there's an + // error resolving a local path, it will be returned untransformed + // so that 'go list -e' reports something useful. importKey := importSpec{ path: path, parentPath: parentPath, |