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
Carlos A Becker 6409998dc8
docs: improving docs
Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
2021-07-10 17:11:37 +00:00

29 lines
744 B
Markdown

# Using the `main.version` ldflag
Defaults-wise GoReleaser sets three _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 according [RFC3339](https://golang.org/pkg/time/#pkg-constants)
You can use them in your `main.go` file to print more build details:
```go
package main
import "fmt"
var (
version = "dev"
commit = "none"
date = "unknown"
builtBy = "unknown"
)
func main() {
fmt.Printf("my app %s, commit %s, built at %s by %s", version, commit, date, builtBy)
}
```
You can override this by changing the `ldflags` option in the [`build` section](/customization/build/).