Skip to content

Instantly share code, notes, and snippets.

@grantpullen
Created December 20, 2019 08:33
Show Gist options
  • Save grantpullen/d5136bd3d20f7ca5472fd55481a7e2c8 to your computer and use it in GitHub Desktop.
Save grantpullen/d5136bd3d20f7ca5472fd55481a7e2c8 to your computer and use it in GitHub Desktop.
Save git build info in Golang linux exec built within Windows
set GOARCH=amd64
set GOOS=linux
set NOW=%date% %time%
rem save the results from 'git describe --tags --dirty --always' to variable 'GINFO'
for /f %%i in ('git describe --tags --dirty --always') do set GINFO=%%i
rem set var GitInfo & var BuildDate in the go code
go build -ldflags "-X 'main.GitInfo=%GINFO%' -X 'main.BuildDate=%NOW%'" -o ./bin/gw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment