Created
July 9, 2021 03:43
-
-
Save nobonobo/99e60744d8d3c8b9f680b3fa67d37261 to your computer and use it in GitHub Desktop.
コンパイル日時をバイナリに埋める方法
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
> go build -ldflags "-X main.Build=$(date +%Y-%m-%dT%H:%M:%S)" sample.go | |
> ./sample.go | |
2021-07-09T12:41:11 |
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 Build = "unknown" | |
func main() { | |
fmt.Println(Build) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment