Skip to content

Commit 9f5309e

Browse files
authored
Add Iterators section in README.md (#3212)
Fixes: #3209.
1 parent 5f496dd commit 9f5309e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,25 @@ for {
316316
}
317317
```
318318

319+
#### Iterators (**experimental**)
320+
321+
Go v1.23 introduces the new `iter` package.
322+
323+
With the `enrichman/gh-iter` package, it is possible to create iterators for `go-github`. The iterator will handle pagination for you, looping through all the available results.
324+
325+
```go
326+
client := github.NewClient(nil)
327+
var allRepos []*github.Repository
328+
329+
// create an iterator and start looping through all the results
330+
repos := ghiter.NewFromFn1(client.Repositories.ListByOrg, "github")
331+
for repo := range repos.All() {
332+
allRepos = append(allRepos, repo)
333+
}
334+
```
335+
336+
For complete usage of `enrichman/gh-iter`, see the full [package docs](https://github.com/enrichman/gh-iter).
337+
319338
### Webhooks ###
320339

321340
`go-github` provides structs for almost all [GitHub webhook events][] as well as functions to validate them and unmarshal JSON payloads from `http.Request` structs.

0 commit comments

Comments
 (0)