Created
January 25, 2022 04:36
-
-
Save jsok/75a7c2914ace98c3ed1aab2be904221c to your computer and use it in GitHub Desktop.
Go Build ID at a particular commit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Shows the build id (as reported by "go list" and "go tool buildid") of a package at a given git ref. | |
COMMIT=${1?Error: supply a commit} | |
PACKAGE=${2?Error: supply a package} | |
git checkout --detach "${COMMIT}" >/dev/null 2>&1 | |
go build -o tmp "${PACKAGE}" >/dev/null 2>&1 | |
echo -n "go tool buildid: " | |
go tool buildid tmp | |
echo -n "go list -e -export -f '{{ .BuildID }}': " | |
go list -e -export -f '{{ .BuildID }}' "${PACKAGE}" | |
git switch - >/dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment