From 9d85908628c598bfc7856d68b1ebbd4a46f0d121 Mon Sep 17 00:00:00 2001 From: Mike Bloy Date: Sat, 24 Aug 2019 16:04:31 -0500 Subject: [PATCH] version data --- version/data.go | 18 ++++++++++++++++++ version/data_test.go | 20 ++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 version/data.go create mode 100644 version/data_test.go diff --git a/version/data.go b/version/data.go new file mode 100644 index 0000000..c945276 --- /dev/null +++ b/version/data.go @@ -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) diff --git a/version/data_test.go b/version/data_test.go new file mode 100644 index 0000000..854010f --- /dev/null +++ b/version/data_test.go @@ -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) + } +}