-
Notifications
You must be signed in to change notification settings - Fork 1
/
version.go
47 lines (41 loc) · 1.09 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
45
46
47
// Copyright (c) 2014-2017 Ludovic Fauvet
// Licensed under the MIT license
package core
import (
"fmt"
"runtime"
)
var (
VERSION = ""
BUILD = ""
DEV = ""
)
// VersionInfo is a struct containing version related informations
type VersionInfo struct {
Version string
Build string
GoVersion string
OS string
Arch string
GoMaxProcs int
}
// GetVersionInfo returns the details of the current build
func GetVersionInfo() VersionInfo {
return VersionInfo{
Version: VERSION,
Build: BUILD + DEV,
GoVersion: runtime.Version(),
OS: runtime.GOOS,
Arch: runtime.GOARCH,
GoMaxProcs: runtime.GOMAXPROCS(0),
}
}
// PrintVersion prints the versions contained in a VersionReply
func PrintVersion(info VersionInfo) {
fmt.Printf(" %-17s %s\n", "Version:", info.Version)
fmt.Printf(" %-17s %s\n", "Build:", info.Build)
fmt.Printf(" %-17s %s\n", "GoVersion:", info.GoVersion)
fmt.Printf(" %-17s %s\n", "Operating System:", info.OS)
fmt.Printf(" %-17s %s\n", "Architecture:", info.Arch)
fmt.Printf(" %-17s %d\n", "Gomaxprocs:", info.GoMaxProcs)
}