Add VersionString func to print out full app version

This commit is contained in:
Dan Sosedoff
2022-12-06 11:27:47 -06:00
parent 3e1a93296e
commit 97e41fbfe5
2 changed files with 22 additions and 15 deletions

View File

@@ -1,5 +1,10 @@
package command
import (
"fmt"
"strings"
)
const (
// Version is the current Pgweb application version
Version = "0.11.12"
@@ -32,3 +37,19 @@ func init() {
Info.BuildTime = BuildTime
Info.GoVersion = GoVersion
}
func VersionString() string {
chunks := []string{fmt.Sprintf("Pgweb v%s", Version)}
if GitCommit != "" {
chunks = append(chunks, fmt.Sprintf("(git: %s)", GitCommit))
}
if GoVersion != "" {
chunks = append(chunks, fmt.Sprintf("(go: %s)", GoVersion))
}
if BuildTime != "" {
chunks = append(chunks, fmt.Sprintf("(build time: %s)", BuildTime))
}
return strings.Join(chunks, " ")
}