summaryrefslogtreecommitdiff
path: root/example_test.go
diff options
context:
space:
mode:
authorJaana Burcu Dogan <jbd@google.com>2016-08-24 15:40:36 -0700
committerJaana Burcu Dogan <jbd@google.com>2016-08-24 22:57:17 +0000
commitc10ba270aa0bf8b8c1c986e103859c67a9103061 (patch)
treef8ee332daad67853dee9054dbe74bca09e169934 /example_test.go
parent54f42edba4a8f81d48dc8b2287b7c7421e673022 (diff)
downloadgolang-x-oauth2-c10ba270aa0bf8b8c1c986e103859c67a9103061.tar.gz
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 <cbro@golang.org>
Diffstat (limited to 'example_test.go')
-rw-r--r--example_test.go6
1 files changed, 4 insertions, 2 deletions
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("...")
}