3 ms·
Golang binaries embed the version of the compiler into them, and can easily add git revision information too. That's a nice feature for adding "foo -version",
by stevekemp 2y ago
Golang binaries embed the version of the compiler into them, and can easily add git revision information too.
That's a nice feature for adding "foo -version", or similar, to show the users what their binaries were built from.
- fanf2 2y agoHere's a nice blog post with more information about that https://blog.carlana.net/post/2023/golang-git-hash-how-to/ https://blog.carlana.net/post/2023/golang-git-hash-how-to/
- peter_l_downs 2y agoI'm currently using the ldflags approach [0], but the linked library [1] looks much nicer. I'll probably switch over to it soon. Thanks! [0]: https://github.com/peterldowns/localias/blob/main/Justfile#L32 https://github.com/peterldowns/localias/blob/main/Justfile#L... [1]: https://github.com/earthboundkid/versioninfo https://github.com/earthboundkid/versioninfo