forked from wkschwartz/pigosat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.go
29 lines (24 loc) · 1004 Bytes
/
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
// Copyright William Schwartz 2014. See the LICENSE file for more information.
package pigosat
import "fmt"
// Struct SemanticVersion implements an immutable semantic version.
type SemanticVersion struct {
major, minor, patch uint
// "a" for alpha, "b" for beta, "c" for release candidate, "" for stable
prerelease string
// Ignored if not a prerelease
step uint
}
func (v SemanticVersion) Major() uint { return v.major }
func (v SemanticVersion) Minor() uint { return v.minor }
func (v SemanticVersion) Patch() uint { return v.patch }
func (v SemanticVersion) Prerelease() string { return v.prerelease }
func (v SemanticVersion) Step() uint { return v.step }
func (v SemanticVersion) IsStable() bool { return v.prerelease == "" }
func (v SemanticVersion) String() string {
var prerelease string
if !v.IsStable() {
prerelease = fmt.Sprintf("%s%d", v.Prerelease(), v.Step())
}
return fmt.Sprintf("%d.%d.%d", v.Major(), v.Minor(), v.Patch()) + prerelease
}