// the find
ahmetb/govvv
"go build" wrapper to add version info to Golang applications
govvv is a thin wrapper around `go build` that injects the git commit, branch, dirty state, `git describe` output, build date, and a VERSION value into package variables via `-ldflags -X`. It is for Go projects that want that metadata without writing linker flags by hand. The author says it is deprecated and unmaintained, so treat it as a reference for the pattern rather than a dependency for new work.
- The `-flags` and `-print` modes make the tool optional at build time. `go build -ldflags="$(govvv -flags)"` works in CI without changing the build command, and `-print` shows exactly what gets injected.
- It appends its `-X` flags to any `-ldflags` the caller already passes instead of overwriting them. That is the detail people usually get wrong when they hand-roll this.
- `-pkg` injects the variables into any package, not just `main`. `debug.ReadBuildInfo` covers the toolchain's build settings but not your own package's variables, so this case still matters.
- The unit tests for the git and ldflags code, plus a bats suite with per-scenario fixture apps (versioned, different package, extra ldflags), mean the flag construction has actually been exercised.
- Go 1.18+ covers most of this natively. `debug.ReadBuildInfo` exposes `vcs.revision`, `vcs.time`, and `vcs.modified` with no flags, and tagged module builds report the module version. For a new project, the wrapper adds a dependency and a nonstandard build command for data the toolchain already embeds.
- Everything depends on shelling out to git at build time. Check what it writes when `.git` is missing, such as a source tarball or a container build, before you trust the output.
- It is a wrapper command, so every caller of `go build` (Makefiles, editor run configs, release scripts) has to be changed to `govvv build`. Any tool that runs plain `go build` produces an unversioned binary without any warning.
- The last push was in March 2023, the CI badge points at Travis, and the install instruction is a `go get` line that predates modules. Nothing will be fixed if a future Go release changes the linker or VCS behavior.