Debian Codegraph @

core/version.go

raw
1 // Copyright (c) 2014-2019 Ludovic Fauvet
2 // Licensed under the MIT license
3
4 package core
5
6 import (
7 "fmt"
8 "runtime"
9 )
10
11 var (
12 VERSION = ""
13 BUILD = ""
14 DEV = ""
15 )
16
17 // VersionInfo is a struct containing version related informations
18 type VersionInfo struct {
19 Version string
20 Build string
21 GoVersion string
22 OS string
23 Arch string
24 GoMaxProcs int
25 }
26
27 // GetVersionInfo returns the details of the current build
28 func GetVersionInfo() VersionInfo {
29 return VersionInfo{
30 Version: VERSION,
31 Build: BUILD + DEV,
32 GoVersion: runtime.Version(),
33 OS: runtime.GOOS,
34 Arch: runtime.GOARCH,
35 GoMaxProcs: runtime.GOMAXPROCS(0),
36 }
37 }
38
39 // PrintVersion prints the versions contained in a VersionReply
40 func PrintVersion(info VersionInfo) {
41 fmt.Printf(" %-17s %s\n", "Version:", info.Version)
42 fmt.Printf(" %-17s %s\n", "Build:", info.Build)
43 fmt.Printf(" %-17s %s\n", "GoVersion:", info.GoVersion)
44 fmt.Printf(" %-17s %s\n", "Operating System:", info.OS)
45 fmt.Printf(" %-17s %s\n", "Architecture:", info.Arch)
46 fmt.Printf(" %-17s %d\n", "Gomaxprocs:", info.GoMaxProcs)
47 }