Go version
go1.26.1 linux/amd64
Output of go env in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/csilvers/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/csilvers/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2900690068=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/csilvers/khan/webapp/go.mod'
GOMODCACHE='/home/csilvers/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/csilvers/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/csilvers/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.1.linux-amd64'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/csilvers/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/csilvers/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.1.linux-amd64/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.26.1'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
Consider this example:
package main
func f() string {
a := "12"
for range 2 {
a += a
}
return a
}
This is using x/tools version v0.42.0.
What did you see happen?
Output from running go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest -fix ./... results in non compiling code:
package main
import "strings"
func f() string {
var a strings.Builder
a.WriteString("12")
for range 2 {
a.WriteString(a).String()
}
return a.String()
}
What did you expect to see?
The line within the loop should be a.WriteString(a.String()).
Go version
go1.26.1 linux/amd64
Output of
go envin your module/workspace:What did you do?
Consider this example:
This is using x/tools version v0.42.0.
What did you see happen?
Output from running
go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest -fix ./...results in non compiling code:What did you expect to see?
The line within the loop should be
a.WriteString(a.String()).