Skip to content

commissure/go-git-build-vars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang Git Build Vars

This is a quick demo of how to set information about your current git repository and build time as variables within your Go binary.

How it works

  1. Gather information and set -ldflags during build in the Makefile
  2. Define variables in your Go code that will be set during build

Variables

This example sets 3 variables:

  1. Timestamp of when the build happens
  2. The current git commit hash, including a ✗- prefix if the working directory is dirty
  3. The current git branch

Run & example output

$ make
$ bin/vars

About

Set build metadata for Golang binaries

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published