-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion.go
More file actions
33 lines (27 loc) · 749 Bytes
/
version.go
File metadata and controls
33 lines (27 loc) · 749 Bytes
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
package gerte
import "fmt"
// Version is the Version used by the Connected Status
type Version struct {
Major byte
Minor byte
Patch byte
}
// ToBytes converts a GERT Version to bytes for sending
func (ver Version) ToBytes() []byte {
return []byte{ver.Major, ver.Minor}
}
// VersionFromBytes parses bytes to a GERT Version
func VersionFromBytes(b []byte) Version {
return Version{
Major: b[0],
Minor: b[1],
}
}
// String prints a GERT Version to a Human-readable string
func (ver Version) String() string {
return fmt.Sprintf("%v.%v.%v", ver.Major, ver.Minor, ver.Patch)
}
// GoString prints a GERT Version to a Human-readable string surrounded with brackets
func (ver Version) GoString() string {
return fmt.Sprintf("[%v]", ver)
}