Use context.Background over oauth2.NoContext

The oauth2.NoContext variable was deprecated in
golang/oauth2@c10ba270aa.
This commit is contained in:
Jackson Owens 2017-05-04 00:46:34 -04:00
parent 83908b1ddd
commit 83030a1ac0
2 changed files with 4 additions and 3 deletions

View File

@ -44,7 +44,7 @@ func (t *TokenSource) Token() (*oauth2.Token, error) {
tokenSource := &TokenSource{
AccessToken: pat,
}
oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)
oauthClient := oauth2.NewClient(context.Background(), tokenSource)
client := godo.NewClient(oauthClient)
```

View File

@ -13,14 +13,15 @@ func ExampleWaitForActive() {
token := &oauth2.Token{AccessToken: pat}
t := oauth2.StaticTokenSource(token)
oauthClient := oauth2.NewClient(oauth2.NoContext, t)
ctx := context.TODO()
oauthClient := oauth2.NewClient(ctx, t)
client := godo.NewClient(oauthClient)
// create your droplet and retrieve the create action uri
uri := "https://api.digitalocean.com/v2/actions/xxxxxxxx"
// block until until the action is complete
err := WaitForActive(context.TODO(), client, uri)
err := WaitForActive(ctx, client, uri)
if err != nil {
panic(err)
}