Fix equal short-long version number comparison
Signed-off-by: Lajos Papp <lajos.papp@sequenceiq.com>
This commit is contained in:
parent
12bfdf1727
commit
76c1b1371b
1 changed files with 10 additions and 5 deletions
|
@ -12,9 +12,17 @@ func (me Version) compareTo(other Version) int {
|
||||||
meTab = strings.Split(string(me), ".")
|
meTab = strings.Split(string(me), ".")
|
||||||
otherTab = strings.Split(string(other), ".")
|
otherTab = strings.Split(string(other), ".")
|
||||||
)
|
)
|
||||||
for i, s := range meTab {
|
|
||||||
|
max := len(meTab)
|
||||||
|
if len(otherTab) > max {
|
||||||
|
max = len(otherTab)
|
||||||
|
}
|
||||||
|
for i := 0; i < max; i++ {
|
||||||
var meInt, otherInt int
|
var meInt, otherInt int
|
||||||
meInt, _ = strconv.Atoi(s)
|
|
||||||
|
if len(meTab) > i {
|
||||||
|
meInt, _ = strconv.Atoi(meTab[i])
|
||||||
|
}
|
||||||
if len(otherTab) > i {
|
if len(otherTab) > i {
|
||||||
otherInt, _ = strconv.Atoi(otherTab[i])
|
otherInt, _ = strconv.Atoi(otherTab[i])
|
||||||
}
|
}
|
||||||
|
@ -25,9 +33,6 @@ func (me Version) compareTo(other Version) int {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(otherTab) > len(meTab) {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue