https://github.com/danielgatis/go-iterator
This package provides an iterator interface and a slice iterator implementation
https://github.com/danielgatis/go-iterator
Last synced: 11 months ago
JSON representation
This package provides an iterator interface and a slice iterator implementation
- Host: GitHub
- URL: https://github.com/danielgatis/go-iterator
- Owner: danielgatis
- License: mit
- Created: 2023-10-07T04:27:03.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-07T05:38:35.000Z (over 2 years ago)
- Last Synced: 2025-07-05T01:39:58.721Z (12 months ago)
- Language: Go
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go - Iterator
[](https://goreportcard.com/report/github.com/danielgatis/go-iterator)
[](https://raw.githubusercontent.com/danielgatis/go-iterator/master/LICENSE)
[](https://godoc.org/github.com/danielgatis/go-iterator)
This package provides an iterator interface and a slice iterator implementation.
## Install
```bash
go get -u github.com/danielgatis/go-iterator
```
And then import the package in your code:
```go
import "github.com/danielgatis/go-iterator"
```
### Example
An example described below is one of the use cases.
```go
package main
import (
"fmt"
"github.com/danielgatis/go-iterator"
)
func main() {
numbers := []int{1, 2, 3, 4, 5}
iter := iterator.NewIterator(numbers)
for iter.HasNext() {
value := iter.GetNextOrDefault(0)
fmt.Println(value)
}
}
```
```
❯ go run main.go
```
### License
Copyright (c) 2023-present [Daniel Gatis](https://github.com/danielgatis)
Licensed under [MIT License](./LICENSE)
### Buy me a coffee
Liked some of my work? Buy me a coffee (or more likely a beer)
