0.2.10 is greater than v0.11.0
rbren opened this issue · 5 comments
rbren commented
Guessing this might have to do with the v
prefix, which should be disregarded.
blang commented
Please provide a code example, especially how you parse v0.11.0 and compare those verions
rbren commented
Looks like an error gets thrown by semver.Make("v0.11.0")
, which we failed to handle.
I'd suggest normalizing versions that start with v
- happy to take a crack at that if you'd accept a PR.
mjhuber commented
package main
import (
"fmt"
"github.com/blang/semver"
)
func main() {
new, newErr := semver.Make("0.2.10")
if newErr != nil {
fmt.Printf("newErr: %v\n",newErr)
}
old, oldErr := semver.Make("v0.11.0")
if oldErr != nil {
fmt.Printf("oldErr: %v\n",oldErr)
}
fmt.Printf("New is set to: %s\nOld is set to: %s\n",new,old)
fmt.Println(new.GT(old))
}
Output:
oldErr: Invalid character(s) found in major number "v0"
New is set to: 0.2.10
Old is set to: 0.0.0
true
blang commented
Please see the ParseTolerant()
func for this usecase
rbren commented
Nice, thanks!