Compare commits
1 Commits
master
...
feature/re
Author | SHA1 | Date |
---|---|---|
Maxim Kuleshov | c7b66c132b |
|
@ -106,23 +106,19 @@ func MustParseVersion(str string) Version {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseVersionFromCode(code uint32) (Version, error) {
|
func ParseVersionFromCode(code uint32) Version {
|
||||||
patch := code % 100
|
patch := code % 100
|
||||||
minor := code%100000 - patch
|
minor := code%100000 - patch
|
||||||
major := code - minor - patch
|
major := code - minor - patch
|
||||||
|
|
||||||
maj, min, p := uint16(major/100000), uint16(minor/100), uint8(patch)
|
maj, min, p := uint16(major/100000), uint16(minor/100), uint8(patch)
|
||||||
|
|
||||||
if err := validate(maj, min, p); err != nil {
|
|
||||||
return Version{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return Version{
|
return Version{
|
||||||
major: maj,
|
major: maj,
|
||||||
minor: min,
|
minor: min,
|
||||||
patch: p,
|
patch: p,
|
||||||
code: code,
|
code: code,
|
||||||
}, nil
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseUint16(str string) (uint16, error) {
|
func parseUint16(str string) (uint16, error) {
|
||||||
|
|
Loading…
Reference in New Issue