Prashant Shahi 48ac20885f
refactor(query-service): ♻️ Update ldflags and Makefile for dynamic versioning (#655)
* refactor(query-service): ♻️  Update ldflags and Makefile for dynamic versioning

Signed-off-by: Prashant Shahi <prashant@signoz.io>

* chore: 🎨 Use blacnk spaces indentation in build details

* chore(query-service): 🎨  small build details format changes

* refactor(query-service): ♻️ refactor ldflags for go build
2022-02-01 23:03:16 +05:30

49 lines
1.0 KiB
Go

package version
import (
"fmt"
"runtime"
"go.uber.org/zap"
)
// These fields are set during an official build
// Global vars set from command-line arguments
var (
buildVersion = "--"
buildHash = "--"
buildTime = "--"
gitBranch = "--"
)
// BuildDetails returns a string containing details about the SigNoz query-service binary.
func BuildDetails() string {
licenseInfo := `Licensed under the MIT License`
return fmt.Sprintf(`
SigNoz version : %v
Commit SHA-1 : %v
Commit timestamp : %v
Branch : %v
Go version : %v
For SigNoz Official Documentation, visit https://signoz.io/docs
For SigNoz Community Slack, visit http://signoz.io/slack
For discussions about SigNoz, visit https://community.signoz.io
%s.
Copyright 2022 SigNoz
`,
buildVersion, buildHash, buildTime, gitBranch,
runtime.Version(), licenseInfo)
}
// PrintVersion prints version and other helpful information.
func PrintVersion() {
zap.S().Infof("\n%s\n", BuildDetails())
}
func GetVersion() string {
return buildVersion
}