# Get version from git tags VERSION := $(shell git describe --tags --always 2>/dev/null) .PHONY: clean testver: ifneq ($(VERSION),) @echo "Building version: $(VERSION)" go build -o testver -ldflags "-X main.Version=$(VERSION)" else @echo "Building without version information" go build -o testver . endif clean: rm -f testver