Open thaJeztah opened 1 day ago
go version go1.23.3 linux/arm64
go env
GO111MODULE='' GOARCH='arm64' GOBIN='' GOCACHE='/root/.cache/go-build' GOENV='/root/.config/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='linux' GOINSECURE='' GOMODCACHE='/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='linux' GOPATH='/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/usr/local/go' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='local' GOTOOLDIR='/usr/local/go/pkg/tool/linux_arm64' GOVCS='' GOVERSION='go1.23.3' GODEBUG='' GOTELEMETRY='local' GOTELEMETRYDIR='/root/.config/go/telemetry' GCCGO='gccgo' GOARM64='v8.0' AR='ar' CC='gcc' CXX='g++' CGO_ENABLED='1' GOMOD='/dev/null' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2955114020=/tmp/go-build -gno-record-gcc-switches'
Ran go mod tidy with a go.mod that contained a stray empty line in a require block
go mod tidy
go.mod
require
Create a minimal module with at least one dependency
mkdir tidy && cd tidy cat > main.go <<'EOF' package main import ( "fmt" "golang.org/x/time/rate" ) var Foo = rate.Limit func main() { fmt.Println("hello") } EOF
Create a go.mod with trailing empty lines in the require section;
cat > go.mod <<'EOF' module tidy go 1.23.0 require ( "golang.org/x/time" v0.8.0 ) EOF
Run go mod tidy;
Check the content of go.mod, and observe that an empty line is left behind in the require section;
cat go.mod module tidy go 1.23.0 require ( golang.org/x/time v0.8.0 )
The empty line was kept even after running go mod tidy
The empty line to be removed.
Related Issues
Related Code Changes
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
CC @golang/tools-team
Go version
go version go1.23.3 linux/arm64
Output of
go env
in your module/workspace:What did you do?
Ran
go mod tidy
with ago.mod
that contained a stray empty line in arequire
blockReproduction steps
Create a minimal module with at least one dependency
Create a go.mod with trailing empty lines in the
require
section;Run
go mod tidy
;Check the content of
go.mod
, and observe that an empty line is left behind in therequire
section;What did you see happen?
The empty line was kept even after running
go mod tidy
What did you expect to see?
The empty line to be removed.