Add global DefaultClient (readonly), WithUserAgent option
Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
@@ -17,22 +17,10 @@ func main() {
|
||||
}
|
||||
|
||||
func run() (err error) {
|
||||
credentials := &reddit.Credentials{
|
||||
ID: "id",
|
||||
Secret: "secret",
|
||||
Username: "username",
|
||||
Password: "password",
|
||||
}
|
||||
|
||||
client, err := reddit.NewClient(credentials)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Let's get the top 200 posts of r/golang.
|
||||
// Reddit returns a maximum of 100 posts at a time,
|
||||
// so we'll need to separate this into 2 requests.
|
||||
result, _, err := client.Subreddit.TopPosts(ctx, "golang", &reddit.ListPostOptions{
|
||||
result, _, err := reddit.DefaultClient.Subreddit.TopPosts(ctx, "golang", &reddit.ListPostOptions{
|
||||
ListOptions: reddit.ListOptions{
|
||||
Limit: 100,
|
||||
},
|
||||
@@ -48,7 +36,7 @@ func run() (err error) {
|
||||
|
||||
// The SetAfter option sets the id of an item that Reddit
|
||||
// will use as an anchor point for the returned listing.
|
||||
result, _, err = client.Subreddit.TopPosts(ctx, "golang", &reddit.ListPostOptions{
|
||||
result, _, err = reddit.DefaultClient.Subreddit.TopPosts(ctx, "golang", &reddit.ListPostOptions{
|
||||
ListOptions: reddit.ListOptions{
|
||||
Limit: 100,
|
||||
After: result.After,
|
||||
|
||||
Reference in New Issue
Block a user