Jay Taylor's notes
back to listing indexgo - Golang application auto build versioning - Stack Overflow
[web search]
Is it possible to increment a minor version number automatically each time a Go app is compiled? I would like to set a version number inside my program, with an autoincrementing section:
Being 0.5 the version number I set, and 132 a value that increments automatically each time the binary is compiled. Is this possible in Go? | |||
add comment | |||
The Go linker (go tool ld) has an option to set the value of an uninitialised string variable:
As part of your build process, you could set a version string variable using this. You can pass this through the
Then:
| |||||||||||||||||||||||||||
|
I don't think it's possible in go. Maybe you can have a version.go which contains a | |||
add comment |
Not with Go's own tool chain. You'll have to hook a script into your build setup somewhere that could do it. You can write one in Go itself. This is how I would go about it:
| |||||||||||||||
|