-
Notifications
You must be signed in to change notification settings - Fork 19k
proposal: debug/buildinfo: export errNotGoExe #67845
Copy link
Copy link
Open
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.GoCommandcmd/gocmd/goNeedsInvestigationSomeone 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.Proposal
Milestone
Metadata
Metadata
Assignees
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.GoCommandcmd/gocmd/goNeedsInvestigationSomeone 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.Proposal
Type
Projects
Status
Incoming
Go version
go1.23-9b43bfbc51
Output of
go envin your module/workspace:What did you do?
Resorted to
//go:linknametricks to get at this value. (link)What did you see happen?
N/A
What did you expect to see?
Without exporting
buildinfo.errNotGoExe, a user must effectively re-implement thedebug/buildinfopackage to determine if an executable is a Go executable and if so, read data to hand toruntime/debug.ParseBuildInfo. If the user doesn't want to copy the logic that decodes the.go.buildinfo(or equivalent) section, the executable ends up needing to be parsed twice to check for the section and magic string.1 Additionally, a user would be unable to use theinternal/saferiohelper.Returning an exported error (or an error that evaluates correctly to a sentinel error with
errors.Is) allows a caller to distinguish between a file that should have valid build info (!errors.Is(err, buildinfo.errNotGoExe)) and a file that's not expected to (errors.Is(err, buildinfo.errNotGoExe)) when the process can't "know" that a-priori.Footnotes
Because sections may be compressed, something like a bitstring search over the file isn't a reliable rule-in/rule-out criteria. To look for a Go-specific section (like
.go.buildinfoor.note.go.buildidin the case of ELF) requires parsing the binary and throwing that work away to havedebug/buildinfoparse it again. ↩