Skip to content

cmd/fix, x/tools/go/analysis: fix can print "applied 8 of 10 fixes; 2 files updated" and fail without actually applying any fixes #77482

@dmitshur

Description

@dmitshur

Go version

go version go1.26rc3 darwin/arm64

Output of go env in your module/workspace:

$ go env -changed | wc -l
       0
Details
AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/gopher/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/gopher/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/s_/5sjqzr0j6xggz_xtzmq_8r4m00jwcj/T/go-build3613773867=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/gopher/go/src/golang.org/x/build/go.mod'
GOMODCACHE='/Users/gopher/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/gopher/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/gopher/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.26rc3'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Change directory into a checkout of the x/build module at its latest commit (golang/build@0556110), and try to run go fix on the golang.org/x/build/dashboard package. (I tried it on all x/build packages, and dashboard was the only one that ran into a problem.)

What did you see happen?

$ go fix ./dashboard
# golang.org/x/build/dashboard
# [golang.org/x/build/dashboard]
fix: applied 8 of 10 fixes; 2 files updated. (Re-run the command to apply more.)
$ echo $?
1
$ git status        
On branch main
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

Notably, go fix claimed it updated 2 files, but it didn't, at least nothing in the x/build module itself. Re-running it produces the same outcome. It's completely reproducible in my environment, but only on this particular package. There doesn't seem to be anything unusual about file permissions.

Details
dashboard $ ls -l  
total 288
-rw-r--r--  1 gopher  primarygroup   35547 Feb  6 11:05 builders_test.go
-rw-r--r--  1 gopher  primarygroup  105307 Feb  6 11:05 builders.go
-rw-r--r--  1 gopher  primarygroup     816 Feb 17  2024 README.md

(That said, it worked fine on all other packages in the module, so this seems like a rare edge case.)

What did you expect to see?

I expected it to update the two builders.go builders_test.go files in package dashboard with 8 of 10 fixes, allowing me to re-run it to apply the remaining 2 out of 10 fixes. I'd also probably expect exit status 0 (i.e., "the work done was partial, but there weren't unexpected errors"), but maybe exiting with status 1 was deemed better to indicate that the work was incomplete.

CC @adonovan, @golang/tools-team.

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions