Skip to content

cmd/go/internal/test: stale flagdefs.go not detected by tests #58415

@empire

Description

@empire

What version of Go are you using (go version)?

$ go version # installed Go
go version go1.19.5 darwin/arm64
$ go version # built Go
go version devel go1.21-1a09d57de5 Wed Feb 8 14:52:12 2023 +0000 darwin/arm64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/hossein/Library/Caches/go-build"
GOENV="/Users/hossein/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/hossein/.local/share/go/pkg/mod"
GONOPROXY=""
GONOSUMDB="gitlab.snapp.ir"
GOOS="darwin"
GOPATH="/Users/hossein/.local/share/go"
GOPRIVATE=""
GOPROXY="https://repo.snapp.tech/repository/goproxy/,goproxy.cn,goproxy.io,direct"
GOROOT="/opt/homebrew/Cellar/go/1.19.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.19.5/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.19.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/hossein/Projects/github.com/golang/go/src/cmd/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/28/0tv7m8993k3859p1zrmyr0th0000gn/T/go-build4070024279=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

In order to implement #37708, I ran the following command to generate the needed files, but the command also changed unrelated lines. This behavior is strange, so I filled this issue based on @ianlancetaylor 's feedback.

The output remains the same when using the built version of Go.

cd src/cmd/go/internal/test
go generate ./...
git diff Output
$ git diff
diff --git a/src/cmd/go/internal/test/flagdefs.go b/src/cmd/go/internal/test/flagdefs.go
index 1e0772fe9c..93681498cb 100644
--- a/src/cmd/go/internal/test/flagdefs.go
+++ b/src/cmd/go/internal/test/flagdefs.go
@@ -23,6 +23,7 @@ var passFlagToTest = map[string]bool{
 	"fuzz":                 true,
 	"fuzzminimizetime":     true,
 	"fuzztime":             true,
+	"gocoverdir":           true,
 	"list":                 true,
 	"memprofile":           true,
 	"memprofilerate":       true,
@@ -50,6 +51,7 @@ var passAnalyzersToVet = map[string]bool{
 	"cgocall":          true,
 	"composites":       true,
 	"copylocks":        true,
+	"directive":        true,
 	"errorsas":         true,
 	"framepointer":     true,
 	"httpresponse":     true,
@@ -67,6 +69,7 @@ var passAnalyzersToVet = map[string]bool{
 	"structtag":        true,
 	"testinggoroutine": true,
 	"tests":            true,
+	"timeformat":       true,
 	"unmarshal":        true,
 	"unreachable":      true,
 	"unsafeptr":        true,

I ran the following command to generate the alldocs.go content. When using the built Go command, everything seems fine, but when using the installed Go command, non-related lines are also changed.

cd src/cmd/go
./mkalldocs.sh
git diff Output
$ git diff
diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go
index 84afcab7a0..a3c1fecb91 100644
--- a/src/cmd/go/alldocs.go
+++ b/src/cmd/go/alldocs.go
@@ -97,13 +97,12 @@
 // ends with a slash or backslash, then any resulting executables
 // will be written to that directory.
 //
+// The -i flag installs the packages that are dependencies of the target.
+// The -i flag is deprecated. Compiled packages are cached automatically.
+//
 // The build flags are shared by the build, clean, get, install, list, run,
 // and test commands:
 //
-//	-C dir
-//		Change to dir before running the command.
-//		Any files named on the command line are interpreted after
-//		changing directories.
 //	-a
 //		force rebuilding of packages that are already up-to-date.
 ... (more output is truncated)

What did you expect to see?

No diff when running the git diff command and the extra lines do not need to be modified.

What did you see instead?

Lines not related to the CL are modified.

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeGoCommandcmd/goNeedsFixThe path to resolution is known, but the work has not been done.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions