make+build: compile go version into binary

This commit is contained in:
Conner Fromknecht 2020-04-09 17:05:24 -07:00
parent 07420835d0
commit d66f15d01f
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
2 changed files with 6 additions and 0 deletions

@ -38,6 +38,7 @@ GOBUILD := GO111MODULE=on go build -v
GOINSTALL := GO111MODULE=on go install -v
GOTEST := GO111MODULE=on go test
GOVERSION := $(shell go version | awk '{print $$3}')
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
GOLIST := go list -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'
GOLISTCOVER := $(shell go list -deps -f '{{.ImportPath}}' ./... | grep '$(PKG)' | sed -e 's/^$(ESCPKG)/./')
@ -53,6 +54,7 @@ DEV_TAGS := $(if ${tags},$(DEV_TAGS) ${tags},$(DEV_TAGS))
make_ldflags = $(shell echo -ldflags \"-X $(PKG)/build.Commit=$(COMMIT) \
-X $(PKG)/build.CommitHash=$(COMMIT_HASH) \
-X $(PKG)/build.GoVersion=$(GOVERSION) \
-X $(PKG)/build.RawTags=$(shell echo $(1) | sed -e 's/ /,/g')\")
LDFLAGS := $(call make_ldflags, ${tags})

@ -24,6 +24,10 @@ var (
// RawTags contains the raw set of build tags, separated by commas. This
// should be set using -ldflags during compilation.
RawTags string
// GoVersion stores the go version that the executable was compiled
// with. This hsould be set using -ldflags during compilation.
GoVersion string
)
// semanticAlphabet is the set of characters that are permitted for use in an