Go version
go version go1.24.3 windows/amd64
Output of go env in your module/workspace:
set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=0
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\zxilly\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=
set GOENV=C:\Users\zxilly\AppData\Roaming\go\env
set GOEXE=
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-fPIC -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\zxilly\AppData\Local\Temp\go-build4032600516=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=T:\gotmp\go.mod
set GOMODCACHE=C:\Users\zxilly\go\pkg\mod
set GONOPROXY=1
set GONOSUMDB=
set GOOS=linux
set GOPATH=C:\Users\zxilly\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTELEMETRY=on
set GOTELEMETRYDIR=C:\Users\zxilly\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.24.3
set GOWASM=
set GOWORK=
set PKG_CONFIG=pkg-config
What did you do?
Write a main.go, then compile it to linux x64 binary.
What did you see happen?
strings binary | grep command-line-arguments, you'll see two duplicate results. In fact, the contents of modinfo are saved twice, once in .go.buildinfo and once in .rodata, with exactly the same contents.
debug.ReadBuildInfo() uses the information in .rodata, while debug/buildinfo.ReadFile() uses the information in .go.buildinfo.
What did you expect to see?
Only save the same content once.
Go version
go version go1.24.3 windows/amd64
Output of
go envin your module/workspace:What did you do?
Write a
main.go, then compile it to linux x64 binary.What did you see happen?
strings binary | grep command-line-arguments, you'll see two duplicate results. In fact, the contents ofmodinfoare saved twice, once in.go.buildinfoand once in.rodata, with exactly the same contents.debug.ReadBuildInfo()uses the information in.rodata, whiledebug/buildinfo.ReadFile()uses the information in.go.buildinfo.What did you expect to see?
Only save the same content once.