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 auto
On Windows OS given the program below
package main
import "fmt"
var (
version string
date string
)
func main() {
fmt.Printf("version=%s, date=%s", version, date)
}
You can build using
go build -ldflags "-X main.version=0.0.1 -X main.date=%date:~10,4%-%date:~4,2%-%date:~7,2%T%time:~0,2%:%time:~3,2%:%time:~6,2%"
Date format assumes your environment echo %date% is Fri 07/22/2016 and echo %time% is 16:21:52.88
Then the output will be: version=0.0.1, date=2016-07-22T16:21:52