Go Tidbit: Setting Variables in Go During Build

from blog Blog on hjr265.me, | ↗ original
Last week I was working on a Go program. I wanted it to print the closest Git tag and build time to logs at startup. I could write a small script that generates a Go file with these two variables set right before building the Go program. But, Go makes it easier. Ldflags Say you have the following Go code: 1 2 3 4 5 6 7 package main var hello...