add build time

This commit is contained in:
MaysWind
2021-02-02 23:02:21 +08:00
parent dc612aef44
commit e1d4e6774c
3 changed files with 52 additions and 20 deletions
+2 -19
View File
@@ -1,23 +1,20 @@
package main
import (
"fmt"
"log"
"os"
"github.com/urfave/cli/v2"
"github.com/mayswind/lab/cmd"
"github.com/mayswind/lab/pkg/version"
)
var version string
var commitHash string
func main() {
app := &cli.App{
Name: "lab",
Usage: "A lightweight account book app hosted by yourself.",
Version: getVersion(),
Version: version.GetFullVersion(),
Commands: []*cli.Command{
cmd.WebServer,
cmd.Database,
@@ -37,17 +34,3 @@ func main() {
log.Fatalf("Failed to run lab app with %s: %v", os.Args, err)
}
}
func getVersion() string {
fullVersion := "Local Build"
if version != "" {
fullVersion = version
}
if commitHash != "" {
fullVersion = fmt.Sprintf("%s (%s)", fullVersion, commitHash)
}
return fullVersion
}