-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
version.go
73 lines (65 loc) · 1.36 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved.
Use of this source code is governed by a Simplified BSD License which
can be found in the LICENSE file.
*/
package main
import (
"fmt"
"runtime"
)
// versionInfo contains build version information.
type versionInfo struct {
major uint64
minor uint64
patch uint64
pre string
}
var (
// tweegoVersion holds the current version info.
tweegoVersion = versionInfo{
major: 2,
minor: 1,
patch: 1,
pre: "",
}
// tweegoVersion holds the build ID.
tweegoBuild = ""
// tweegoVersion holds the build date.
tweegoDate = ""
)
// String returns the full version string (version, date, and platform).
func (v versionInfo) String() string {
date := tweegoDate
if date != "" {
date = " (" + date + ")"
}
return fmt.Sprintf("version %s%s [%s]", v.Version(), date, v.Platform())
}
// Version returns the SemVer version string.
func (v versionInfo) Version() string {
pre := v.pre
if pre != "" {
pre = "-" + pre
}
build := tweegoBuild
if build != "" {
build = "+" + build
}
return fmt.Sprintf(
"%d.%d.%d%s%s",
v.major,
v.minor,
v.patch,
pre,
build,
)
}
// Date returns the build date string.
func (v versionInfo) Date() string {
return tweegoDate
}
// Platform returns the OS/Arch pair.
func (v versionInfo) Platform() string {
return runtime.GOOS + "/" + runtime.GOARCH
}