Skip to content
This repository was archived by the owner on Oct 28, 2020. It is now read-only.
This repository was archived by the owner on Oct 28, 2020. It is now read-only.

infra: Implement scanner-style Slack API pagination #15

Description

@riking

Function in a similar manner to Python's generators.

https://godoc.org/bufio#ex-Scanner--Lines
https://godoc.org/database/sql#Rows

https://api.slack.com/methods/conversations.members

type PaginatedSlackResponse struct {
    // filtered fields
}

func (r *PaginatedSlackResponse) Next() bool
func (r *PaginatedSlackResponse) Scan(v interface{}) error
func (r *PaginatedSlackResponse) Err() error

func ExamplePaginatedSlackResponse() {
    var userID string
    pages := slackapi.Paged("conversations.members", "C2BTT0LD6", "members")
    for pages.Next() {
        err = pages.Scan(&userID)
        if err != nil { panic(errors.Wrap(err, "Bad unmarshal")) }

        // use userID...
    }
    if pages.Err() != nil {
        // handle error...
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions