1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
goreleaser/www/docs/cookbooks/using-main.version.md
2022-09-27 12:04:47 -03:00

725 B

Using the main.version ldflag

By default, GoReleaser will set the following 3 ldflags:

  • main.version: Current Git tag (the v prefix is stripped) or the name of the snapshot, if you're using the --snapshot flag
  • main.commit: Current git commit SHA
  • main.date: Date in the RFC3339 format

You can use them in your main.go file to print more build details:

package main

import "fmt"

var (
	version = "dev"
	commit  = "none"
	date    = "unknown"
)

func main() {
  fmt.Printf("my app %s, commit %s, built at %s", version, commit, date)
}

You can override this by changing the ldflags option in the build section.