Go 1 · Quality and release builds
Set a version at build time
Set a string variable in package main from the command line.
go build -ldflags "-X main.version=1.2.3" -o myapp .
Go 1 · Quality and release builds
Set a string variable in package main from the command line.
go build -ldflags "-X main.version=1.2.3" -o myapp .
Was this page helpful?