Skip to content

Instantly share code, notes, and snippets.

@FlowingSPDG
Last active August 2, 2020 02:18
Show Gist options
  • Save FlowingSPDG/7292c81452f177ec2519391a9e51399a to your computer and use it in GitHub Desktop.
Save FlowingSPDG/7292c81452f177ec2519391a9e51399a to your computer and use it in GitHub Desktop.
Goでコンパイル時に変数を埋め込む方法(ShellScript)
Now=$(date +%Y.%m.%d.%H%M%S)
go build -ldflags "-X main.buildedAt=$Now"
package main
import (
"fmt"
)
var (
buildedAt = ""
)
func main() {
fmt.Println("Builded at:", buildedAt)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment