Skip to content

Instantly share code, notes, and snippets.

@dbehnke
Created May 10, 2016 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbehnke/52b4eefd998ca5430ed3c0acb5ed916a to your computer and use it in GitHub Desktop.
Save dbehnke/52b4eefd998ca5430ed3c0acb5ed916a to your computer and use it in GitHub Desktop.
Using git tags to generate version strings
go build -ldflags "-X main.Version=`git describe --tags --long`" test.go
./test
# 4.16.5-DEV-0-g9a95002
import (
"fmt"
)
var Version = "Nothing Set"
func main() {
fmt.Println(Version)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment