jiahua wang has uploaded this change for review.
cmd/go: better error message for when line having '@'
Fix #50713
Change-Id: Iefb0bd30f6dee3feef46fb9369b9941cc2de2263
---
M src/cmd/go/go_test.go
M src/cmd/go/internal/load/pkg.go
M src/cmd/go/testdata/script/mod_versions.txt
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index 7aaec4e..6918a69 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -2658,12 +2658,12 @@
tg.tempFile("src/@x/x.go", "package x\n")
tg.setenv("GOPATH", tg.path("."))
tg.runFail("build", "@x")
- tg.grepStderr("invalid input directory name \"@x\"|can only use path@version syntax with 'go get' and 'go install' in module-aware mode", "did not reject @x directory")
+ tg.grepStderr("invalid input directory name \"@x\"|can only use path@version syntax with 'go get' and 'go install' and 'go list -m ...' in module-aware mode", "did not reject @x directory")
tg.tempFile("src/@x/y/y.go", "package y\n")
tg.setenv("GOPATH", tg.path("."))
tg.runFail("build", "@x/y")
- tg.grepStderr("invalid import path \"@x/y\"|can only use path@version syntax with 'go get' and 'go install' in module-aware mode", "did not reject @x/y import path")
+ tg.grepStderr("invalid import path \"@x/y\"|can only use path@version syntax with 'go get' and 'go install' and 'go list -m ...' in module-aware mode", "did not reject @x/y import path")
tg.tempFile("src/-x/x.go", "package x\n")
tg.setenv("GOPATH", tg.path("."))
diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
index fca9d5a..5724274 100644
--- a/src/cmd/go/internal/load/pkg.go
+++ b/src/cmd/go/internal/load/pkg.go
@@ -796,7 +796,7 @@
}
if strings.Contains(path, "@") {
- return nil, false, errors.New("can only use path@version syntax with 'go get' and 'go install' in module-aware mode")
+ return nil, false, errors.New("can only use path@version syntax with 'go get' and 'go install' and 'go list -m ...' in module-aware mode")
}
// Determine canonical package path and directory.
diff --git a/src/cmd/go/testdata/script/mod_versions.txt b/src/cmd/go/testdata/script/mod_versions.txt
index 9e6322b..efdfa9a 100644
--- a/src/cmd/go/testdata/script/mod_versions.txt
+++ b/src/cmd/go/testdata/script/mod_versions.txt
@@ -3,12 +3,12 @@
! go get rsc.io/qu...@v1.5.1
stderr '^go: can only use path@version syntax with ''go get'' and ''go install'' in module-aware mode$'
! go build rsc.io/qu...@v1.5.1
-stderr '^package rsc.io/qu...@v1.5.1: can only use path@version syntax with ''go get'' and ''go install'' in module-aware mode$'
+stderr '^package rsc.io/qu...@v1.5.1: can only use path@version syntax with ''go get'' and ''go install'' and ''go list -m ...'' in module-aware mode$'
env GO111MODULE=on
cd x
! go build rsc.io/qu...@v1.5.1
-stderr '^package rsc.io/qu...@v1.5.1: can only use path@version syntax with ''go get'' and ''go install'' in module-aware mode$'
+stderr '^package rsc.io/qu...@v1.5.1: can only use path@version syntax with ''go get'' and ''go install'' and ''go list -m ...'' in module-aware mode$'
-- x/go.mod --
module x
To view, visit change 381195. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Bryan Mills, Michael Matloob, jiahua wang.
1 comment:
Patchset:
Ping bcmills. Do we want this for 1.19? Thanks.
To view, visit change 381195. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Michael Matloob, jiahua wang.
1 comment:
File src/cmd/go/internal/load/pkg.go:
Patch Set #2, Line 824: 'go get' and 'go install' and 'go list -m ...'
This list of commands is getting pretty long, and even with this addition it is missing an entry for `go run`, from proposal #42088.
I'm not sure what to do about that, but I don't think it makes sense to just keep expanding a list of commands that don't necessarily have anything to do with what the user intended to do.
To view, visit change 381195. To unsubscribe, or for help writing mail filters, visit settings.