Skip to content

Commit

Permalink
Add Iterators section in README.md (#3212)
Browse files Browse the repository at this point in the history
Fixes: #3209.
  • Loading branch information
enrichman committed Jul 19, 2024
1 parent 5f496dd commit 9f5309e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,25 @@ for {
}
```

#### Iterators (**experimental**)

Go v1.23 introduces the new `iter` package.

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.

```go
client := github.NewClient(nil)
var allRepos []*github.Repository

// create an iterator and start looping through all the results
repos := ghiter.NewFromFn1(client.Repositories.ListByOrg, "github")
for repo := range repos.All() {
allRepos = append(allRepos, repo)
}
```

For complete usage of `enrichman/gh-iter`, see the full [package docs](https://github.com/enrichman/gh-iter).

### Webhooks ###

`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.
Expand Down

0 comments on commit 9f5309e

Please sign in to comment.