API Reference

PREVIEW DOCUMENTATION - This is a preview of a new format for the AWS SDK for Go API Reference documentation. For the current AWS SDK for Go API Reference, see

We welcome your feedback on this new version of the documentation. Send your comments to


import ""

type Pagination struct { NewRequest func() (*Request, error) EndPageOnSameToken bool }

A Pagination provides paginating of SDK API operations which are paginatable. Generally you should not use this type directly, but use the "Pages" API operations method to automatically perform pagination for you. Such as, "S3.ListObjectsPages", and "S3.ListObjectsPagesWithContext" methods.

Pagination differs from a Paginator type in that pagination is the type that does the pagination between API operations, and Paginator defines the configuration that will be used per page request.

cont := true for p.Next() && cont { data := p.Page().(*s3.ListObjectsOutput) // process the page's data } return p.Err()

See service client API operation Pages methods for examples how the SDK will use the Pagination type.


Type: func() (*Request, error)

Function to return a Request value for each pagination request. Any configuration or handlers that need to be applied to the request prior to getting the next page should be done here before the request returned.

NewRequest should always be built from the same API operations. It is undefined if different API operations are returned on subsequent calls.


Type: bool

EndPageOnSameToken, when enabled, will allow the paginator to stop on token that are the same as its previous tokens.



func (p *Pagination) Err() error

Err returns the error Pagination encountered when retrieving the next page.


func (p *Pagination) HasNextPage() bool

HasNextPage will return true if Pagination is able to determine that the API operation has additional pages. False will be returned if there are no more pages remaining.

Will always return true if Next has not been called yet.


func (p *Pagination) Next() bool

Next will attempt to retrieve the next page for the API operation. When a page is retrieved true will be returned. If the page cannot be retrieved, or there are no more pages false will be returned.

Use the Page method to retrieve the current page data. The data will need to be cast to the API operation's output type.

Use the Err method to determine if an error occurred if Page returns false.


func (p *Pagination) Page() interface{}

Page returns the current page. Page should only be called after a successful call to Next. It is undefined what Page will return if Page is called after Next returns false.

On this page: