prysm-pulse/shared/version/version.go
Raul Jordan 546196a6fa
Other Package Godocs for Prysm (#5681)
* e2e docs
* slasher docs
* Merge branch 'other-package-godocs' of github.com:prysmaticlabs/prysm into other-package-godocs
* all validator package comments
* Merge branch 'master' into other-package-godocs
* completed all other packages
* Merge branch 'master' into other-package-godocs
* Merge refs/heads/master into other-package-godocs
2020-04-29 21:32:39 +00:00

34 lines
828 B
Go

// Package version executes and returns the version string
// for the currently running process.
package version
import (
"fmt"
"log"
"os/exec"
"strings"
"time"
)
// The value of these vars are set through linker options.
var gitCommit = "Local build"
var buildDate = "Moments ago"
// GetVersion returns the version string of this build.
func GetVersion() string {
// if doing a local build, these values are not interpolated
if gitCommit == "{STABLE_GIT_COMMIT}" {
commit, err := exec.Command("git", "rev-parse", "HEAD").Output()
if err != nil {
log.Println(err)
} else {
gitCommit = strings.TrimRight(string(commit), "\r\n")
}
}
if buildDate == "{DATE}" {
now := time.Now().Format(time.RFC3339)
buildDate = now
}
return fmt.Sprintf("Prysm/Git commit: %s. Built at: %s", gitCommit, buildDate)
}