aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/load.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2018-10-09 09:50:56 -0400
committerBryan C. Mills <bcmills@google.com>2018-10-09 20:10:02 +0000
commit6c85693bf14e246e5a53466048329cb7571a674c (patch)
treeb41c87562ff68c32a3113103aaab78b25c14ff14 /src/cmd/go/internal/modload/load.go
parent48dc42b6afe7ad13102c55b8200c9f4577a88c84 (diff)
downloadgo-6c85693bf14e246e5a53466048329cb7571a674c.tar.gz
go-6c85693bf14e246e5a53466048329cb7571a674c.zip
cmd/go: check that package paths are invariantly non-empty
The empty string is never a valid package path. Passing an empty string to a function that expects a package path indicates some missing validation step further up the call chain — typically (and most easily) a missed error check. Change-Id: I78a2403d95b473bacb0d40814cd9d477ecfd5351 Reviewed-on: https://go-review.googlesource.com/c/140857 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modload/load.go')
-rw-r--r--src/cmd/go/internal/modload/load.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go
index 6c1525da9a..3b8c0b6435 100644
--- a/src/cmd/go/internal/modload/load.go
+++ b/src/cmd/go/internal/modload/load.go
@@ -397,6 +397,9 @@ func ModuleUsedDirectly(path string) bool {
// Lookup requires that one of the Load functions in this package has already
// been called.
func Lookup(path string) (dir, realPath string, err error) {
+ if path == "" {
+ panic("Lookup called with empty package path")
+ }
pkg, ok := loaded.pkgCache.Get(path).(*loadPkg)
if !ok {
// The loader should have found all the relevant paths.