Skip to content

Instantly share code, notes, and snippets.

@mosajjal
Created January 6, 2024 23:01
Show Gist options
  • Save mosajjal/ad1d9778c17789720bce9bca9d14467f to your computer and use it in GitHub Desktop.
Save mosajjal/ad1d9778c17789720bce9bca9d14467f to your computer and use it in GitHub Desktop.
get build info of a go binary
package main
import (
"debug/buildinfo"
"encoding/json"
"flag"
"fmt"
"log"
)
func main() {
filename := flag.String("filename", "", "File path to use")
flag.Parse()
if info, err := buildinfo.ReadFile(*filename); err != nil {
log.Fatal(err)
} else {
j, _ := json.Marshal(info)
fmt.Println(string(j))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment