Embed version info in a Golang binary


In the source:

var COMMIT string;

In the go build command:

go build -ldflags "-X github.com/FileFormatInfo/badger/cmd.COMMIT=$(git rev-parse --short HEAD)"

source

Date: 2020-01-03

Tags:  golang

Share: