Skip to content

Instantly share code, notes, and snippets.

@billhathaway
Created September 2, 2016 13:41
Show Gist options
  • Save billhathaway/4b006176c3ede87adb4a995168ac317b to your computer and use it in GitHub Desktop.
Save billhathaway/4b006176c3ede87adb4a995168ac317b to your computer and use it in GitHub Desktop.
passing in values during go build time
 package main

 import "fmt"
  
   var (
     version  = "develop"
     otherval = "unset"
   )
   
 func main() {
     fmt.Println(version)
     fmt.Println(otherval)
 }

go build -ldflags="-X main.version=$123 -X main.otherval=abc"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment