Next Return the next item in the result set and advance the iterator. Advancing the iterator may require fetching a new page.
()
| 865 | // Next Return the next item in the result set and advance the iterator. |
| 866 | // Advancing the iterator may require fetching a new page. |
| 867 | func (cli *ChangeLogIterator) Next() *ChangeLogEntry { |
| 868 | if cli.Err != nil { |
| 869 | return nil |
| 870 | } |
| 871 | |
| 872 | item := cli.message.Entries[cli.itemIdx] |
| 873 | if cli.itemIdx+1 < len(cli.message.Entries) { |
| 874 | // We still have an item left in the currently cached page |
| 875 | cli.itemIdx++ |
| 876 | } else { |
| 877 | if cli.message.IsLastPage() { |
| 878 | cli.Err = errDone |
| 879 | } else { |
| 880 | // There are still more pages to fetch, so fetch the next page and |
| 881 | // cache it |
| 882 | cli.message, cli.Err = cli.client.GetChangeLog( |
| 883 | cli.idOrKey, cli.pageSize, cli.message.NextStartAt()) |
| 884 | // NOTE(josh): we don't deal with the error now, we just cache it. |
| 885 | // HasNext() will return false and the caller can check the error |
| 886 | // afterward. |
| 887 | cli.itemIdx = 0 |
| 888 | } |
| 889 | } |
| 890 | return &item |
| 891 | } |
| 892 | |
| 893 | // IterChangeLog returns an iterator over entries in the changelog for an issue |
| 894 | func (client *Client) IterChangeLog(idOrKey string, pageSize int) *ChangeLogIterator { |
no test coverage detected