Go version

go version go1.22.3 linux/amd64

Output of go env in your module/workspace:

vscode ➜ /workspaces/Discord_GitHub-Utilities (master) $ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/vscode/.cache/go-build'
GOENV='/home/vscode/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
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_amd64'
GOVCS=''
GOVERSION='go1.22.3'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/workspaces/Discord_GitHub-Utilities/go.mod'
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1864882069=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Checked: runtime/debug.BuildInfo.Path == runtime/debug.BuildInfo.Main.Path

What did you see happen?

Confirmed: runtime/debug.BuildInfo.Path == runtime/debug.BuildInfo.Main.Path

What did you expect to see?

Remove runtime/debug.BuildInfo.Path as redundant with runtime/debug.BuildInfo.Main.Path

References

  • https://github.com/golang/go/blob/90bcc552c0347948166817a602f612f219bc980c/src/runtime/debug/mod.go#L46-L51

  • https://github.com/golang/go/blob/90bcc552c0347948166817a602f612f219bc980c/src/runtime/debug/mod.go#L63

Comment From: gabyhelp

Similar Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: ianlancetaylor

Thanks, but we can't make that change now. It would break the Go 1 compatibility guarantee (https://go.dev/s/go1compat).

Comment From: seankhliao

runtime/debug.BuildInfo.Path is the main package path runtime/debug.BuildInfo.Main.Path is the main module path they are only equal when the main package is at the root of the module.

Comment From: Malix-Labs

@seankhliao then, would it be able to clarify it in the comments documentation ?

https://github.com/golang/go/blob/90bcc552c0347948166817a602f612f219bc980c/src/runtime/debug/mod.go#L46-L48

path of the main package

This is misleading

Comment From: ianlancetaylor

What is misleading about it? How would you write it? Thanks.

Comment From: Malix-Labs

runtime/debug.BuildInfo.Path:

Path is the package path of the current package for the binary

As runtime/debug.BuildInfo.Main.Path is "the package path of the main package for the binary"

If i'm not mistaken, of course

Comment From: seankhliao

there is no "current" package, and Main.Path is not a package path

Comment From: Malix-Labs

Do you mean the difference is between package and modules ?