hashicorp / hashicorp/go-version
Edge cases
- Dominant language
- Go
- Stars
- 1.8k
- Forks
- 165
- Avg merge
- 23h 42m
- Merged PRs (30d)
- 2
Description
Is that how it should be? Are there any other well-known libraries for such cases?
```
import (
"fmt"
"sort"
"github.com/hashicorp/go-version"
)
func Sort(versionsRaw []string) []*version.Version {
versions := make([]*version.Version, len(versionsRaw))
for i, raw := range versionsRaw {
v, _ := version.NewSemver(raw)
versions[i] = v
}
sort.Sort(version.Collection(versions))
return versions
}
func main() {
fmt.Println(Sort([]string{"v0.0.2-rc5", "v0.0.2-rc9",})) // [0.0.2-rc5 0.0.2-rc9]
fmt.Println(Sort([]string{"v0.0.2-rc10", "v0.0.2-rc9",})) // [0.0.2-rc10 0.0.2-rc9]
fmt.Println(Sort([]string{"v0.10.3-ps.v5", "v0.10.3-ps.v9",})) // [0.10.3-ps.v5 0.10.3-ps.v9]
fmt.Println(Sort([]string{"v0.10.3-ps.v10", "v0.10.3-ps.v9",})) // [0.10.3-ps.v10 0.10.3-ps.v9]
}
```
Contributor guide
Research direction
Start by running the Go example from the issue and inspect the version parsing and sorting APIs it uses. Determine the expected ordering for the shown prerelease cases and whether the behavior is intentional. Done requires a maintainer decision plus either a focused regression test or a documented limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100