github.com/lyft/flytestdlib@v0.3.12-0.20210213045714-8cdd111ecda1/version/version.go (about) 1 package version 2 3 import ( 4 "time" 5 6 "github.com/sirupsen/logrus" 7 ) 8 9 // This module provides the ability to inject Build (git sha) and Version information at compile time. 10 // To set these values invoke go build as follows 11 // go build -ldflags “-X github.com/lyft/flytestdlib/version.Build=xyz -X github.com/lyft/flytestdlib/version.Version=1.2.3" 12 // NOTE: If the version is set and server.StartProfilingServerWithDefaultHandlers are initialized then, `/version` 13 // will provide the build and version information 14 var ( 15 // Specifies the GIT sha of the build 16 Build = "unknown" 17 // Version for the build, should follow a semver 18 Version = "unknown" 19 // Build timestamp 20 BuildTime = time.Now().String() 21 ) 22 23 // Use this method to log the build information for the current app. The app name should be provided. To inject the build 24 // and version information refer to the top-level comment in this file 25 func LogBuildInformation(appName string) { 26 logrus.Info("------------------------------------------------------------------------") 27 logrus.Infof("App [%s], Version [%s], BuildSHA [%s], BuildTS [%s]", appName, Version, Build, BuildTime) 28 logrus.Info("------------------------------------------------------------------------") 29 }