Add Makefile
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
d4fefd8176
commit
b2a45c3aba
7 changed files with 78 additions and 17 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue