MCPcopy Index your code
hub / github.com/google/go-github / ListIter

Method ListIter

github/github-iterators.go:3230–3258  ·  view source on GitHub ↗

ListIter returns an iterator that paginates through all results of List.

(ctx context.Context, user string, opts *GistListOptions)

Source from the content-addressed store, hash-verified

3228
3229// ListIter returns an iterator that paginates through all results of List.
3230func (s *GistsService) ListIter(ctx context.Context, user string, opts *GistListOptions) iter.Seq2[*Gist, error] {
3231 return func(yield func(*Gist, error) bool) {
3232 // Create a copy of opts to avoid mutating the caller's struct
3233 if opts == nil {
3234 opts = &GistListOptions{}
3235 } else {
3236 opts = Ptr(*opts)
3237 }
3238
3239 for {
3240 results, resp, err := s.List(ctx, user, opts)
3241 if err != nil {
3242 yield(nil, err)
3243 return
3244 }
3245
3246 for _, item := range results {
3247 if !yield(item, nil) {
3248 return
3249 }
3250 }
3251
3252 if resp.NextPage == 0 {
3253 break
3254 }
3255 opts.ListOptions.Page = resp.NextPage
3256 }
3257 }
3258}
3259
3260// ListAllIter returns an iterator that paginates through all results of ListAll.
3261func (s *GistsService) ListAllIter(ctx context.Context, opts *GistListOptions) iter.Seq2[*Gist, error] {

Calls 2

ListMethod · 0.95
PtrFunction · 0.70