Last active
March 27, 2019 01:36
-
-
Save peacefixation/a0f1c69ffa161118b211f71c334bd79e to your computer and use it in GitHub Desktop.
Set version variable to Git hash at compile time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://goenning.net/2017/01/25/adding-custom-data-go-binaries-compile-time/ | |
# https://golang.org/cmd/link/ | |
GIT_HASH=$(shell git rev-parse HEAD) | |
FLAGS=-ldflags "-X main.version=$(GIT_HASH)" | |
build: | |
@go build $(FLAGS) | |
run: | |
@go run $(FLAGS) main.go | |
clean: | |
@rm app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment