Created
January 6, 2024 23:01
-
-
Save mosajjal/ad1d9778c17789720bce9bca9d14467f to your computer and use it in GitHub Desktop.
get build info of a go binary
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
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