Cleanup Makefile. Add version flag.

This commit is contained in:
2024-05-06 15:10:45 +02:00
parent fcc8eac2d5
commit 8c9761fe2a
2 changed files with 38 additions and 107 deletions

View File

@@ -4,6 +4,7 @@ import (
"bufio"
"context"
"flag"
"fmt"
"log"
"os"
"os/signal"
@@ -19,13 +20,27 @@ import (
"github.com/google/gops/agent"
)
var (
date string
commit string
version string
)
func main() {
var configFile string
var enableGopsAgent bool
var enableGopsAgent, flagVersion bool
flag.StringVar(&configFile, "config", "./config.json", "configuration file")
flag.BoolVar(&enableGopsAgent, "gops", false, "Listen via github.com/google/gops/agent")
flag.BoolVar(&flagVersion, "version", false, "Show version information and exit")
flag.Parse()
if flagVersion {
fmt.Printf("Version:\t%s\n", version)
fmt.Printf("Git hash:\t%s\n", commit)
fmt.Printf("Build time:\t%s\n", date)
os.Exit(0)
}
startupTime := time.Now()
config.Init(configFile)
memorystore.Init(config.Keys.Metrics)