add method to fill VersionNum from string values

This commit is contained in:
denver 2023-02-13 19:57:53 +03:00
parent f44e6b104b
commit 145c56e9f6

View File

@ -1,7 +1,9 @@
package domain
import "strconv"
type JavaVersion struct {
VersionNums `json:"version"`
VersionNums `json:"versionnums"`
Specifics []JavaVersionSpecifics `json:"specifics"`
}
@ -27,6 +29,31 @@ type VersionNums struct {
Patch int `json:"patch"`
}
func (v *VersionNums) FillFromString(maj string, min string, patch string) error {
iMaj, err := strconv.Atoi(maj)
if err != nil {
return err
}
iMin := 0
iMin, err = strconv.Atoi(min)
if err != nil {
return err
}
iPatch := 0
iPatch, err = strconv.Atoi(patch)
if err != nil {
return err
}
v.Major = iMaj
v.Minor = iMin
v.Patch = iPatch
return nil
}
type Version struct {
AssetIndex AssetIndex `json:"assetIndex"`
Downloads struct {