-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.
Milestone
Description
Go version
go version go1.25.4 darwin/arm64
Output of go env in your module/workspace:
AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/bian/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/bian/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/dt/w56r82l955v2r8yndkc5p2lc0000gn/T/go-build2386555638=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/bian/tmp/go.mod'
GOMODCACHE='/Users/bian/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/bian/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.25.4/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/bian/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.25.4/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25.4'
GOWORK=''
PKG_CONFIG='pkg-config'What did you do?
Consider this example
package main
import "fmt"
func main() {
var (
str = "hello world"
)
for range 100 {
str += "!"
}
fmt.Println(str)
}
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"
import "fmt"
func main() {
var (
str strings.Builder; str.WriteString("hello world"
))
for range 100 {
str .WriteString("!")
}
fmt.Println(str.String())
}What did you expect to see?
I expected to see something like
package main
import "strings"
import "fmt"
func main() {
var (
str strings.Builder
)
str.WriteString("hello world")
for range 100 {
str.WriteString("!")
}
fmt.Println(str.String())
}where the initial expression is appended after the declaration block.
I would like to open an issue to fix this bug if I could
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.