Last active
October 21, 2019 16:56
-
-
Save ggzeng/64a0f1ce9d70c066cd7394d5fd8fd667 to your computer and use it in GitHub Desktop.
在build编译的时候初始化包中的变量
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
package main | |
import "fmt" | |
var ( | |
VERSION string | |
BUILD_TIME string | |
GO_VERSION string | |
) | |
func main() { | |
fmt.Printf("%s\n%s\n%s\n", VERSION, BUILD_TIME, GO_VERSION) | |
} | |
// go build -ldflags "-X main.VERSION=1.0.0 -X 'main.BUILD_TIME=`date -u +.%Y%m%d.%H%M%S`' -X 'main.GO_VERSION=`go version`'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment