Documentation ¶
Overview ¶
Package iterator contains helper for working with iterators. It is meant for internal use only by the Go Client Libraries.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RangeAdapter ¶
RangeAdapter transforms client iterator type into a iter.Seq2 that can be used with Go's range expressions.
This is for internal use only.
Example ¶
//go:build go1.23 package main import ( "fmt" "iter" "github.com/googleapis/gax-go/v2/iterator" otherit "google.golang.org/api/iterator" ) type exampleType struct { data []int i int } func (t *exampleType) next() (int, error) { var v int if t.i == len(t.data) { return v, otherit.Done } v = t.data[t.i] t.i++ return v, nil } func (t *exampleType) All() iter.Seq2[int, error] { return iterator.RangeAdapter[int](t.next) } func main() { t := &exampleType{ data: []int{1, 2, 3}, } for v, err := range t.All() { if err != nil { // TODO: handle error } fmt.Println(v) } }
Output: 1 2 3
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.