Skip to content

Instantly share code, notes, and snippets.

@kevinadi
Created June 27, 2019 01:42
Show Gist options
  • Save kevinadi/f4a72a038f028aff58edbfde466073c1 to your computer and use it in GitHub Desktop.
Save kevinadi/f4a72a038f028aff58edbfde466073c1 to your computer and use it in GitHub Desktop.
Makefile for Go to automatically stamp Git info and build date
version=$(shell git describe --always --long --dirty)
date=$(shell date -j "+(%b %Y)")
all:
@go build -v -ldflags '-X "main.version=${version}" -X "main.date=${date}"'
install:
@go install -v -ldflags '-X "main.version=${version}" -X "main.date=${date}"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment