We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v1, _ := version.NewVersion("") v2, _ := version.NewVersion("10.3") if v1.LessThan(v2) { fmt.Println("v1<v2") } else { fmt.Println("v2<v1") }
goroutine 1 [running]: github.com/hashicorp/go-version.(*Version).String(0x0) /go/pkg/mod/github.com/hashicorp/go-version@v1.6.0/version.go:369 +0x33 github.com/hashicorp/go-version.(*Version).Compare(0xc000080140, 0x0) /go/pkg/mod/github.com/hashicorp/go-version@v1.6.0/version.go:116 +0x39 github.com/hashicorp/go-version.(*Version).GreaterThan(...) /go/pkg/mod/github.com/hashicorp/go-version@v1.6.0/version.go:298 main.main() /workspaces/learning/rc/string.go:18 +0x95 exit status 2
The text was updated successfully, but these errors were encountered:
To avoid a panic it's needed adding a check to handle the case where version.NewVersion returns an error for an empty version string:
version.NewVersion
v1, err := version.NewVersion("") if err != nil { fmt.Printf("v1 error: %q\n", err) // Output: v1 error: Malformed version: return } v2, err := version.NewVersion("10.3") if err != nil { fmt.Printf("v2 error: %v\n", err) return } if v1.LessThan(v2) { fmt.Println("v1<v2") } else { fmt.Println("v2<v1") }
Sorry, something went wrong.
No branches or pull requests
goroutine 1 [running]:
github.com/hashicorp/go-version.(*Version).String(0x0)
/go/pkg/mod/github.com/hashicorp/go-version@v1.6.0/version.go:369 +0x33
github.com/hashicorp/go-version.(*Version).Compare(0xc000080140, 0x0)
/go/pkg/mod/github.com/hashicorp/go-version@v1.6.0/version.go:116 +0x39
github.com/hashicorp/go-version.(*Version).GreaterThan(...)
/go/pkg/mod/github.com/hashicorp/go-version@v1.6.0/version.go:298
main.main()
/workspaces/learning/rc/string.go:18 +0x95
exit status 2
The text was updated successfully, but these errors were encountered: