forked from kuskoman/logstash-exporter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
version.go
44 lines (37 loc) · 1.05 KB
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package config
import (
"fmt"
"runtime"
)
var (
// Version is the current version of Logstash Exporter.
Version = "unknown"
// GitCommit is the git commit hash of the current build.
GitCommit = "unknown"
// BuildDate is the date of the current build.
BuildDate = "unknown"
)
// GetVersionInfo returns a VersionInfo struct with the current build information.
func GetVersionInfo() *VersionInfo {
return &VersionInfo{
Version: Version,
GitCommit: GitCommit,
GoVersion: runtime.Version(),
BuildArch: runtime.GOARCH,
BuildOS: runtime.GOOS,
BuildDate: BuildDate,
}
}
// VersionInfo contains the current build information.
type VersionInfo struct {
Version string
GitCommit string
GoVersion string
BuildArch string
BuildOS string
BuildDate string
}
// String returns a string representation of the VersionInfo struct.
func (v *VersionInfo) String() string {
return fmt.Sprintf("Version: %s, GitCommit: %s, GoVersion: %s, BuildArch: %s, BuildOS: %s, BuildDate: %s", v.Version, v.GitCommit, v.GoVersion, v.BuildArch, v.BuildOS, v.BuildDate)
}