Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rosbit/list-fetcher
utility to fetch list page by page and change the results to an iterator. 翻页数据转化为迭代器的神器。
https://github.com/rosbit/list-fetcher
golang iterator list-fetcher page-fetcher
Last synced: about 7 hours ago
JSON representation
utility to fetch list page by page and change the results to an iterator. 翻页数据转化为迭代器的神器。
- Host: GitHub
- URL: https://github.com/rosbit/list-fetcher
- Owner: rosbit
- License: mit
- Created: 2022-09-29T06:21:28.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-10-09T09:55:51.000Z (about 2 years ago)
- Last Synced: 2024-06-21T11:03:47.557Z (5 months ago)
- Topics: golang, iterator, list-fetcher, page-fetcher
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# list-fetcher, a utility to fetch list page by page and change the results to an iterator
## Interface to implement
```go
import (
"encoding/json"
)type PageFetcher interface {
GetNextPage() (total int64, list []json.RawMessage, err error)
AdjustPage(list []json.RawMessage)
HasMore() bool // called if total is 0
ErrorOccurrs(err error)
}
```### Utility functions
```go
func FetchList(pf PageFetcher) (total int64, it <-chan json.RawMessage, err error) {
//
}func Dump(w io.Writer, it <-chan json.RawMessage) {
//
}
func DumpJSON(w io.Writer, it <-chan json.RawMessage) {
//
}
```### Usage
See [list-fetcher_test.go](list-fetcher_test.go)