Skip to content

Instantly share code, notes, and snippets.

@leopku
Created July 3, 2018 14:25
Show Gist options
  • Save leopku/19506105fe9dd139ed85f988a80d0d18 to your computer and use it in GitHub Desktop.
Save leopku/19506105fe9dd139ed85f988a80d0d18 to your computer and use it in GitHub Desktop.
how to build a go program with git revision
BUILD = `git rev-parse HEAD`
LDFLAGS=-ldflags "-X 'main.schema=$(SCHEMA)' -X 'main.build=$(BUILD)'"
build:
go build -a $(LDFLAGS) -o ./build/server ./cmd/server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment