Skip to content
New issue

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

When i compare with Empty version string Getting Error #132

Open
vinaykumarva opened this issue Mar 15, 2024 · 0 comments
Open

When i compare with Empty version string Getting Error #132

vinaykumarva opened this issue Mar 15, 2024 · 0 comments

Comments

@vinaykumarva
Copy link

vinaykumarva commented Mar 15, 2024

v1, _ := version.NewVersion("")
	v2, _ := version.NewVersion("10.3")
	if v1.LessThan(v2) {
		fmt.Println("v1<v2")
	} else {
		fmt.Println("v2<v1")
	}
panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x4a3bd3]

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant