File: version.go

package info (click to toggle)
mirrorbits 0.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 984 kB
  • sloc: sh: 675; makefile: 93
file content (47 lines) | stat: -rw-r--r-- 1,113 bytes parent folder | download | duplicates (2)
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-2019 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)
}