https://github.com/karnott/grange
Grange is a range library to manipulate date and number range in Golang
https://github.com/karnott/grange
go golang range ranges
Last synced: 6 months ago
JSON representation
Grange is a range library to manipulate date and number range in Golang
- Host: GitHub
- URL: https://github.com/karnott/grange
- Owner: Karnott
- License: mit
- Created: 2022-06-17T10:20:52.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-13T14:22:54.000Z (almost 3 years ago)
- Last Synced: 2024-06-21T13:00:32.473Z (over 1 year ago)
- Topics: go, golang, range, ranges
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Grange
Grange is range library to manipulate date and number range
# Install
```bash
# v1
go get github.com/karnott/grange
# v2
go get github.com/karnott/grange/v2
```
# [V2] How to use it (check v1 package for correct struct name)
```go
import github.com/karnott/grange
func main() {
range1 := grange.NumberRange[int]{1, 10}
range2 := grange.NumberRange[int]{5, 20}
rangeIntersection := range.Intersection(range1, range2)
// rangeIntersection == [2]NumberRange[int]{5, 10}
}
```
# Compatibility
You need to use Golang 1.18 or newer version
# TODO
- [x] range intersection
- [ ] range union
- [x] range difference
- [ ] range contain
- [ ] range before
- [ ] range after