Compare commits
No commits in common. "feature/remove_validation_from_code" and "master" have entirely different histories.
feature/re
...
master
|
@ -106,19 +106,23 @@ func MustParseVersion(str string) Version {
|
|||
return v
|
||||
}
|
||||
|
||||
func ParseVersionFromCode(code uint32) Version {
|
||||
func ParseVersionFromCode(code uint32) (Version, error) {
|
||||
patch := code % 100
|
||||
minor := code%100000 - patch
|
||||
major := code - minor - 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{
|
||||
major: maj,
|
||||
minor: min,
|
||||
patch: p,
|
||||
code: code,
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func parseUint16(str string) (uint16, error) {
|
||||
|
|
Loading…
Reference in New Issue