Created
July 9, 2018 15:54
-
-
Save mhamrah/b2b337c826763f6893d7e4d61b2bffe8 to your computer and use it in GitHub Desktop.
Set go variable with LD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"fmt" | |
) | |
// use ldflags to set this var at build time: | |
// go build -ldflags "-X main.version=$(git tag)" | |
// go build -ldflags "-X main.version=$(git rev-parse HEAD)" | |
var version string | |
func main() { | |
fmt.Printf("version: %v\n", version) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment