From c10ba270aa0bf8b8c1c986e103859c67a9103061 Mon Sep 17 00:00:00 2001 From: Jaana Burcu Dogan Date: Wed, 24 Aug 2016 15:40:36 -0700 Subject: all: deprecate NoContext There is no good reason why we suggest NoContext rather than context.Background(). When the oauth2 library first came around, the community was not familiar with the x/net/context package. For documentation reasons, we decided to add NoContext to the oauth2 package. It was not a good idea even back then. And given that context package is fairly popular, there is no good reason why we are depending on this. Updating all the references of NoContext with context.Background and documenting it as deprecated. Change-Id: I18e390f1351023a29b567777a3f963dd550cf657 Reviewed-on: https://go-review.googlesource.com/27690 Reviewed-by: Chris Broadfoot --- example_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'example_test.go') diff --git a/example_test.go b/example_test.go index f5ac863..d861fe7 100644 --- a/example_test.go +++ b/example_test.go @@ -5,6 +5,7 @@ package oauth2_test import ( + "context" "fmt" "log" @@ -12,6 +13,7 @@ import ( ) func ExampleConfig() { + ctx := context.Background() conf := &oauth2.Config{ ClientID: "YOUR_CLIENT_ID", ClientSecret: "YOUR_CLIENT_SECRET", @@ -35,11 +37,11 @@ func ExampleConfig() { if _, err := fmt.Scan(&code); err != nil { log.Fatal(err) } - tok, err := conf.Exchange(oauth2.NoContext, code) + tok, err := conf.Exchange(ctx, code) if err != nil { log.Fatal(err) } - client := conf.Client(oauth2.NoContext, tok) + client := conf.Client(ctx, tok) client.Get("...") } -- cgit v1.2.3