aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Matloob <matloob@golang.org>2025-12-30 15:41:41 -0500
committerGopher Robot <gobot@golang.org>2025-12-30 14:29:01 -0800
commitb28808d838682b2911698fcb934813b02f39fa69 (patch)
treefef356c796782c7d2659231a16507da38d43582a
parentd64add4d60b69973e5cae62f07983f91435de58b (diff)
downloadgo-b28808d838682b2911698fcb934813b02f39fa69.tar.xz
cmd/go/internal/modindex: fix obvious bug using failed type assertion
adonovan pointed out this bug in the review of CL 733320 and this seems to be the cause of all those list_empty_importpath flakes. It makes sense that something nondeterministic would be tied up with the module index because the state of the cache could depend on the order tests are run in. Also remove the parts of the test that accept the flaky behavior so we can verify the issue has been resolved. For #73976 Change-Id: Ib64ce6b8eed1dc8d327b7c5e842c1e716a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/733321 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com>
-rw-r--r--src/cmd/go/internal/modindex/scan.go6
-rw-r--r--src/cmd/go/testdata/script/list_empty_importpath.txt11
2 files changed, 4 insertions, 13 deletions
diff --git a/src/cmd/go/internal/modindex/scan.go b/src/cmd/go/internal/modindex/scan.go
index af2c0abe04..beded695bf 100644
--- a/src/cmd/go/internal/modindex/scan.go
+++ b/src/cmd/go/internal/modindex/scan.go
@@ -112,10 +112,10 @@ func parseErrorToString(err error) string {
return ""
}
var p parseError
- if e, ok := err.(scanner.ErrorList); ok {
- p.ErrorList = &e
+ if errlist, ok := err.(scanner.ErrorList); ok {
+ p.ErrorList = &errlist
} else {
- p.ErrorString = e.Error()
+ p.ErrorString = err.Error()
}
s, err := json.Marshal(p)
if err != nil {
diff --git a/src/cmd/go/testdata/script/list_empty_importpath.txt b/src/cmd/go/testdata/script/list_empty_importpath.txt
index fe4210322b..0960a7795d 100644
--- a/src/cmd/go/testdata/script/list_empty_importpath.txt
+++ b/src/cmd/go/testdata/script/list_empty_importpath.txt
@@ -1,15 +1,6 @@
! go list all
! stderr 'panic'
-[!GOOS:windows] [!GOOS:solaris] [!GOOS:freebsd] [!GOOS:openbsd] [!GOOS:netbsd] stderr 'invalid import path'
-# #73976: Allow 'no errors' on Windows, Solaris, and BSD until issue
-# is resolved to prevent flakes. 'no errors' is printed by
-# empty scanner.ErrorList errors so that's probably where the
-# message is coming from, though we don't know how.
-[GOOS:windows] stderr 'invalid import path|no errors'
-[GOOS:solaris] stderr 'invalid import path|no errors'
-[GOOS:freebsd] stderr 'invalid import path|no errors'
-[GOOS:openbsd] stderr 'invalid import path|no errors'
-[GOOS:netbsd] stderr 'invalid import path|no errors'
+stderr 'invalid import path'
# go list produces a package for 'p' but not for ''
go list -e all