go run -ldflags "-s \
-X main.Version=1.0.2 \
-X main.BuildTime=`TZ=UTC date -u '+%Y-%m-%dT%H:%M:%SZ'` \
-X main.GitHash=`git rev-parse HEAD`" \
myapp.go
Adopted from www.atatus.com
go run -ldflags "-s \
-X main.Version=1.0.2 \
-X main.BuildTime=`TZ=UTC date -u '+%Y-%m-%dT%H:%M:%SZ'` \
-X main.GitHash=`git rev-parse HEAD`" \
myapp.go
Adopted from www.atatus.com
package main | |
import "fmt" | |
var ( | |
Version = "undefined" | |
BuildTime = "undefined" | |
GitHash = "undefined" | |
) | |
func main() { | |
fmt.Printf("Version : %s\n", Version) | |
fmt.Printf("Git Hash : %s\n", GitHash) | |
fmt.Printf("Build Time : %s\n", BuildTime) | |
} |