version data

This commit is contained in:
Mike Bloy 2019-08-24 16:04:31 -05:00
parent 12b62ccee4
commit 9d85908628
2 changed files with 38 additions and 0 deletions

18
version/data.go Normal file
View File

@ -0,0 +1,18 @@
package version
import (
"fmt"
"runtime"
)
// gitDescribe : Git's "git describe --always --dirty" output
var gitDescribe = ""
// BuildDate : Date of this build in YYYY-MM-DD format
var BuildDate = ""
// GoVersion : The go version used to compile this binary
var GoVersion = runtime.Version()
// OsArch : The OS and archetcture used for this binary
var OsArch = fmt.Sprintf("%s (%s)", runtime.GOOS, runtime.GOARCH)

20
version/data_test.go Normal file
View File

@ -0,0 +1,20 @@
package version
import "testing"
import "runtime"
func TestGoVersion(t *testing.T) {
got := GoVersion
expected := runtime.Version()
if got != expected {
t.Errorf("Expected: %s ; Got: %s", got, expected)
}
}
func TestOsArch(t *testing.T) {
got := OsArch
expected := runtime.GOOS + " (" + runtime.GOARCH + ")"
if got != expected {
t.Errorf("Expected: %s ; Got: %s", got, expected)
}
}