Skip to content

Latest commit

 

History

History
35 lines (22 loc) · 1.7 KB

File metadata and controls

35 lines (22 loc) · 1.7 KB

listpages

The listpages generator creates paginated variants of AWS Go SDK functions that return collections of objects where the SDK does not define them. It should typically be called using go generate.

For example, the EC2 API defines both DescribeInstancesPages and DescribeInstances, whereas the EventBridge API defines only ListEventBuses.

The listpages executable is called as follows:

$ go run main.go -ListOps <function-name>[,<function-name>] [<generated-lister-file>]
  • <function-name>: Name of a function to wrap
  • <generated-lister-file>: Name of the generated lister source file, defaults to list_pages_gen.go

Optional Flags:

  • -Paginator: Name of the pagination token field (default NextToken)
  • -Export: Whether to export the generated functions

To use with go generate, add the following directive to a Go file

//go:generate go run <relative-path-to-generators>/generate/listpages/main.go -ListOps=<comma-separated-list-of-functions>

For example, in the file internal/service/events/generate.go

//go:generate go run ../../generate/listpages/main.go -ListOps=ListEventBuses,ListRules,ListTargetsByRule

package events

generates the file internal/service/events/list_pages_gen.go with the functions listEventBusesPages, listRulesPages, and listTargetsByRulePages as well as their ...WithContext equivalents.