From bf2ccb4969025692ea06adf6d1ff7abc9a3a1245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Sun, 28 Apr 2024 10:54:43 +0200 Subject: [PATCH] Minor change --- cmd/main.go | 3 +-- version.go | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 03199c75..cae629e1 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -78,8 +78,7 @@ func start(cliCtx *cli.Context) error { setupLog(c.Log) - agglayer.PrintVersion(os.Stdout) - log.Info("Starting application...") + log.Infof("Starting application... %s", agglayer.GetVersionInfo()) // Prepare DB pg, err := dbConf.NewSQLDB(c.DB) diff --git a/version.go b/version.go index 40464fdd..6681c660 100644 --- a/version.go +++ b/version.go @@ -16,10 +16,16 @@ var ( // PrintVersion prints version info into the provided io.Writer. func PrintVersion(w io.Writer) { - fmt.Fprintf(w, "Version: %s\n", Version) - fmt.Fprintf(w, "Git revision: %s\n", GitRev) - fmt.Fprintf(w, "Git branch: %s\n", GitBranch) - fmt.Fprintf(w, "Go version: %s\n", runtime.Version()) - fmt.Fprintf(w, "Built: %s\n", BuildDate) - fmt.Fprintf(w, "OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) + fmt.Fprint(w, GetVersionInfo()) +} + +// GetVersionInfo returns version information as a formatted string. +func GetVersionInfo() string { + versionInfo := fmt.Sprintf("Version: %s\n", Version) + versionInfo += fmt.Sprintf("Git revision: %s\n", GitRev) + versionInfo += fmt.Sprintf("Git branch: %s\n", GitBranch) + versionInfo += fmt.Sprintf("Go version: %s\n", runtime.Version()) + versionInfo += fmt.Sprintf("Built: %s\n", BuildDate) + versionInfo += fmt.Sprintf("OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) + return versionInfo }