gitlab.com/evatix-go/core@v1.3.55/corecmp/VersionSliceInteger.go (about) 1 package corecmp 2 3 import "gitlab.com/evatix-go/core/corecomparator" 4 5 func VersionSliceInteger(leftVersions, rightVersions []int) corecomparator.Compare { 6 if leftVersions == nil && rightVersions == nil { 7 return corecomparator.Equal 8 } 9 10 if leftVersions == nil || rightVersions == nil { 11 return corecomparator.NotEqual 12 } 13 14 leftLen := len(leftVersions) 15 rightLen := len(rightVersions) 16 minLength := corecomparator.MinLength( 17 leftLen, 18 rightLen) 19 20 for i := 0; i < minLength; i++ { 21 cLeft := leftVersions[i] 22 cRight := rightVersions[i] 23 24 if cLeft == cRight { 25 continue 26 } else if cLeft < cRight { 27 return corecomparator.LeftLess 28 } else if cLeft > cRight { 29 return corecomparator.LeftGreater 30 } 31 } 32 33 if leftLen == rightLen { 34 return corecomparator.Equal 35 } else if leftLen < rightLen { 36 return corecomparator.LeftLess 37 } else if leftLen > rightLen { 38 return corecomparator.LeftGreater 39 } 40 41 return corecomparator.NotEqual 42 }