Add Makefile

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2021-03-17 12:25:35 +01:00
parent d4fefd8176
commit b2a45c3aba
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7
7 changed files with 78 additions and 17 deletions

View file

@ -20,6 +20,15 @@ import (
// AppVersion stores application version at compilation time
var AppVersion string
// AppName to store application name
var AppName string = "pgterminate"
// GitCommit to set git commit at compilation time (can be empty)
var GitCommit string
// GoVersion to set Go version at compilation time
var GoVersion string
func main() {
var err error
config := base.NewConfig()
@ -68,7 +77,7 @@ func main() {
if AppVersion == "" {
AppVersion = "unknown"
}
fmt.Println(AppVersion)
showVersion()
return
}
@ -179,3 +188,10 @@ func removePid(file string) {
base.Panic(err)
}
}
func showVersion() {
if GitCommit != "" {
AppVersion = fmt.Sprintf("%s-%s", AppVersion, GitCommit)
}
fmt.Printf("%s version %s (compiled with %s)\n", AppName, AppVersion, GoVersion)
}