Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime/debug.BuildInfo.Path: redundant with runtime/debug.BuildInfo.Main.Path #68177

Closed
Malix-off opened this issue Jun 25, 2024 · 8 comments
Closed

Comments

@Malix-off
Copy link

Malix-off commented Jun 25, 2024

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

  • // Path is the package path of the main package for the binary
    // (for example, "golang.org/x/tools/cmd/stringer").
    Path string
    // Main describes the module that contains the main package for the binary.
    Main Module

  • Path string // module path

@ianlancetaylor
Copy link
Contributor

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

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Jun 25, 2024
@seankhliao
Copy link
Member

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.

@Malix-off
Copy link
Author

Malix-off commented Jun 26, 2024

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

// Path is the package path of the main package for the binary
// (for example, "golang.org/x/tools/cmd/stringer").
Path string

path of the main package

This is misleading

@ianlancetaylor
Copy link
Contributor

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

@Malix-off
Copy link
Author

Malix-off commented Jun 26, 2024

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

@seankhliao
Copy link
Member

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

@Malix-off
Copy link
Author

Do you mean the difference is between package and modules ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants