From 65af7278c0fc7a421db0c173459b5a1efffc690c Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio Date: Thu, 23 Feb 2017 20:41:35 -0500 Subject: [PATCH] Update README with context.Context usage. (#127) * Update README with context.Context usage. * s/Background/TODO/ --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 03d0c07..4d5cdf8 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,9 @@ createRequest := &godo.DropletCreateRequest{ }, } -newDroplet, _, err := client.Droplets.Create(createRequest) +ctx := context.TODO() + +newDroplet, _, err := client.Droplets.Create(ctx, createRequest) if err != nil { fmt.Printf("Something bad happened: %s\n\n", err) @@ -78,14 +80,14 @@ if err != nil { If a list of items is paginated by the API, you must request pages individually. For example, to fetch all Droplets: ```go -func DropletList(client *godo.Client) ([]godo.Droplet, error) { +func DropletList(ctx context.Context, client *godo.Client) ([]godo.Droplet, error) { // create a list to hold our droplets list := []godo.Droplet{} // create options. initially, these will be blank opt := &godo.ListOptions{} for { - droplets, resp, err := client.Droplets.List(opt) + droplets, resp, err := client.Droplets.List(ctx, opt) if err != nil { return nil, err }