Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jbowes/semver
🦔 semver and constraint parsing with a focus on performance
https://github.com/jbowes/semver
go golang hacktoberfest parser ragel semver semver-parser
Last synced: 2 months ago
JSON representation
🦔 semver and constraint parsing with a focus on performance
- Host: GitHub
- URL: https://github.com/jbowes/semver
- Owner: jbowes
- License: bsd-3-clause
- Created: 2021-08-26T18:37:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-07T12:55:39.000Z (about 1 year ago)
- Last Synced: 2024-06-21T15:24:26.406Z (6 months ago)
- Topics: go, golang, hacktoberfest, parser, ragel, semver, semver-parser
- Language: Go
- Homepage:
- Size: 82 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
semver
🦔 semver and constraint parsing with a focus on performance
---
[`semver`][godoc] provides semantic version and constraint parsing, comparison,
and testing.There are many semver packages. This one aims to be the fastest at parsing
and comparing values, with low memory usage. On average, this package is roughly
ten times faster at parsing versions and constraints than the popular
`Masterminds/semver` and `hashicorp/go-version` packages. View more stats in
the [benchmarks][bench].Versions can be compared with one another to determine which is newer.
Constraints specify inclusions and exclusions of semver ranges that a given
version must satisfy. Typically, constraints are used when expressing a
dependency.## Quick start
```go
import (
"log""github.com/jbowes/semver"
)func main() {
// Parse a version. Two versions can also be Compare()ed
ver, err := semver.Parse("1.0.2")
if err != nil {
log.Fatal("invalid semver")
}// Parse a Constraint, typically used to express dependency
constr, err := semver.ParseConstraint(">=1.0.0")
if err != nil {
log.Fatalln("invalid constraint")
}// Check if a Version satisfies a Constraint
if constr.Check(ver) {
log.Printf("%s satisfies constraint %s\n", ver, constr)
} else {
log.Printf("%s does not satisfy constraint %s\n", ver, constr)
}
}
```For more usage and examples, see the [GoDoc Reference][godoc]
## Contributing
I would love your help!
`semver` is still a work in progress. You can help by:
- Opening a pull request to resolve an [open issue][issues].
- Adding a feature or enhancement of your own! If it might be big, please
[open an issue][enhancement] first so we can discuss it.
- Improving this `README` or adding other documentation to `semver`.
- Letting [me] know if you're using `semver`.## Links
- [Semantic Versioning 2.0.0][semver]
- [npm semver calculator][calc]
- [npm semver range BNF][npmbnf]
- [Benchmarks][bench][semver]: https://semver.org
[calc]: https://semver.npmjs.com/
[npmbnf]: https://github.com/npm/node-semver/blob/master/range.bnf
[bench]: https://github.com/jbowes/semver/blob/main/BENCHMARK.md[godoc]: https://pkg.go.dev/github.com/jbowes/semver
[issues]: ./issues
[bug]: ./issues/new?labels=bug
[enhancement]: ./issues/new?labels=enhancement[me]: https://twitter.com/jrbowes