page.go (package eai)
Source: sdks/go/page.go. Back to the Go SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Class Page
Page is one page of a cursor paginated collection {"items": [...], "next_cursor": "..."|null}.
Fields:
| Name | Type | Required | Description |
|---|---|---|---|
Items | []json.RawMessage | yes | Items of this page as raw JSON; decode them with Decode or json.Unmarshal. |
NextCursor | string | yes | Cursor of the next page (next_cursor), empty on the last page. |
Page.HasNext
HasNext() bool
HasNext reports whether another page exists.
This element takes no parameter.
Returns: bool. true when NextCursor is not empty.
Page.Iter
Iter() *Iterator
Iter returns an iterator over every item of this page and the following ones.
This element takes no parameter.
Returns: *Iterator. An *Iterator positioned before the first item of this page.
Page.Next
Next(ctx context.Context) (*Page, error)
Next fetches the following page.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
ctx | context.Context | yes | Context of the call: cancellation and deadline. |
Returns: (*Page, error). A Page: Page is one page of a cursor paginated collection {"items": [...], "next_cursor": "..."|null}. The error is a typed error of the SDK, nil on success.
Raises: error.
Class Iterator
Iterator walks every item across pages, fetching lazily.
Iterator.All
All(ctx context.Context) ([]json.RawMessage, error)
All collects every remaining item.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
ctx | context.Context | yes | Context of the call: cancellation and deadline. |
Returns: ([]json.RawMessage, error). Every remaining item as raw JSON, and the error that stopped the walk, nil when every page was read.
Raises: error.
Iterator.Err
Err() error
Err returns the error that stopped the iteration, if any.
This element takes no parameter.
Returns: error. Error of the call (a typed error of the SDK), nil on success.
Raises: error.
Iterator.Item
Item() json.RawMessage
Item returns the current item.
This element takes no parameter.
Returns: json.RawMessage. Raw JSON of the current item; call it only after Next returned true.
Iterator.Next
Next(ctx context.Context) bool
Next advances; it returns false at the end or on error (see Err).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
ctx | context.Context | yes | Context of the call: cancellation and deadline. |
Returns: bool. true when an item is available, fetching the next page when the current one is used up.