Go
Location: examples/go/
Go's linker injects string values via -ldflags:
examples/go/main.go
package main
import "fmt"
// VERSION will be set by the linker during build
var VERSION = "0.0.0"
func main() {
fmt.Printf("Sample Go Application\n")
fmt.Printf("Version: %s\n", VERSION)
}
examples/go/Makefile (excerpt)
build:
VERSION=$$(versionator version); \
go build -ldflags "-X main.VERSION=$$VERSION" -o sample-app .
Run it
$ cd examples/go && just run
Getting version from versionator...
Building sample application with version: 0.0.16
Build completed: sample-app
./sample-app
Sample Go Application
Version: 0.0.16