louis's Blog

louis's Avatar Image
Software developer #Go #CommonLisp #JS #SQL. #LispWorks user. Soft spots for #Emacs #SmallWeb. Recently becoming #OpenBSD enthusiast.

Author of the Tuner app for Linux.

Other hobbies: #Running #FireFighter #StarTrek
← All posts

TIL: Go 1.18+ can read the Git revision the binary was built from during runtime:

var commit = func() string {
	if info, ok := debug.ReadBuildInfo(); ok {
		for _, setting := range info.Settings {
			if setting.Key == "vcs.revision" {
				return setting.Value
			}
		}
	}
	return ""
}()

fmt.Printf("Git Rev. %s\n", commit)

Very useful to print the revision on startup to make sure you are actually using the right version.

#golang

To like or reply, open original post on Emacs.ch