Remove validation from ParseVersionFromCode

This commit is contained in:
Maxim Kuleshov 2022-10-17 11:10:12 +03:00
parent 50c2c27060
commit c7b66c132b
1 changed files with 2 additions and 6 deletions

View File

@ -106,23 +106,19 @@ func MustParseVersion(str string) Version {
return v
}
func ParseVersionFromCode(code uint32) (Version, error) {
func ParseVersionFromCode(code uint32) Version {
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) {