Quick Start
The quick start guide describes how to set up version
with the most common way of creating CLIs in Go. It uses Cobra and GoReleaser.
Register the version
command
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
This way you get a fully working <cli> version
command.
GoReleaser versioning info with -ldflags
# .goreleaser.yaml
builds:
- # .. your settings ..
ldflags:
- -s -w
- -X go.szostok.io/version.version={{.Version}}
- -X go.szostok.io/version.buildDate={{.Date}}
Summary
As you saw, in the blink of an eye, you got a powerful version
command! However, this only scratches the surfaces of possible configuration options.
You can easily customize the version
command and adjust it to give you exactly what you need.
For more details, see the documentation: