You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run go version -m on a non-Go executable, and then test the exit code of the go command. My use case is writing a script that detects whether a file is a Go executable or not, and only runs certain logic if so.
$ go version -m /bin/sh
$ echo $?
What did you see happen?
I saw a zero exit code, indicating success:
$ go version -m /bin/sh
/bin/sh: could not read Go build info from /bin/sh: not a Go executable
$ echo $?
0
What did you expect to see?
Since go version -m encountered an error, I expected to see a non-zero exit code, e.g.:
$ go version -m /bin/sh
/bin/sh: could not read Go build info from /bin/sh: not a Go executable
$ echo $?
1
The text was updated successfully, but these errors were encountered:
I think this error can be a little misleading. Not all Go binaries have embedded build info. We should probably return a non zero exit but for maybe we should reword the error to not mislead people.
Go version
go version go1.22.1 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Run
go version -m
on a non-Go executable, and then test the exit code of the go command. My use case is writing a script that detects whether a file is a Go executable or not, and only runs certain logic if so.What did you see happen?
I saw a zero exit code, indicating success:
What did you expect to see?
Since
go version -m
encountered an error, I expected to see a non-zero exit code, e.g.:The text was updated successfully, but these errors were encountered: