Skip to content

Commit c453e0c

Browse files
sapkbradfitz
authored andcommitted
all: use stdlib context instead of x/net/context
This PR replaces use of `x/net/context` with the standard `context` It has been nearly 6 months since golang#246 (comment) so I made this PR so it will be ready to merge when needed (and if possible). Fixes golang#246 Change-Id: Id2c316fcb27de0fb9163ceb4e8669b04cb39a987 GitHub-Last-Rev: 5b36321 GitHub-Pull-Request: golang#339 Reviewed-on: https://go-review.googlesource.com/c/145202 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 5a69e67 commit c453e0c

16 files changed

+21
-20
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ See godoc for further documentation and examples.
2424

2525
In change 96e89be (March 2015), we removed the `oauth2.Context2` type in favor
2626
of the [`context.Context`](https://golang.org/x/net/context#Context) type from
27-
the `golang.org/x/net/context` package
27+
the `golang.org/x/net/context` package. Later replaced by the standard `context` package
28+
of the [`context.Context`](https://golang.org/pkg/context#Context) type.
29+
2830

2931
This means it's no longer possible to use the "Classic App Engine"
3032
`appengine.Context` type with the `oauth2` package. (You're using
@@ -44,7 +46,7 @@ with the `oauth2` package.
4446

4547
```go
4648
import (
47-
"golang.org/x/net/context"
49+
"context"
4850
"golang.org/x/oauth2"
4951
"golang.org/x/oauth2/google"
5052
newappengine "google.golang.org/appengine"

clientcredentials/clientcredentials.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
package clientcredentials // import "golang.org/x/oauth2/clientcredentials"
1515

1616
import (
17+
"context"
1718
"fmt"
1819
"net/http"
1920
"net/url"
2021
"strings"
2122

22-
"golang.org/x/net/context"
2323
"golang.org/x/oauth2"
2424
"golang.org/x/oauth2/internal"
2525
)

google/appengine.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
package google
66

77
import (
8+
"context"
89
"time"
910

10-
"golang.org/x/net/context"
1111
"golang.org/x/oauth2"
1212
)
1313

google/default.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package google
66

77
import (
8+
"context"
89
"encoding/json"
910
"fmt"
1011
"io/ioutil"
@@ -14,7 +15,6 @@ import (
1415
"runtime"
1516

1617
"cloud.google.com/go/compute/metadata"
17-
"golang.org/x/net/context"
1818
"golang.org/x/oauth2"
1919
)
2020

google/example_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
package google_test
66

77
import (
8+
"context"
89
"fmt"
910
"io/ioutil"
1011
"log"
1112
"net/http"
1213

13-
"golang.org/x/net/context"
1414
"golang.org/x/oauth2"
1515
"golang.org/x/oauth2/google"
1616
"golang.org/x/oauth2/jwt"

google/go19.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
package google
88

99
import (
10-
"golang.org/x/net/context"
10+
"context"
11+
1112
"golang.org/x/oauth2"
1213
)
1314

google/google.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
package google
66

77
import (
8+
"context"
89
"encoding/json"
910
"errors"
1011
"fmt"
1112
"strings"
1213
"time"
1314

1415
"cloud.google.com/go/compute/metadata"
15-
"golang.org/x/net/context"
1616
"golang.org/x/oauth2"
1717
"golang.org/x/oauth2/jwt"
1818
)

google/not_go19.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
package google
88

99
import (
10-
"golang.org/x/net/context"
10+
"context"
11+
1112
"golang.org/x/oauth2"
1213
)
1314

google/sdk.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package google
66

77
import (
88
"bufio"
9+
"context"
910
"encoding/json"
1011
"errors"
1112
"fmt"
@@ -18,7 +19,6 @@ import (
1819
"strings"
1920
"time"
2021

21-
"golang.org/x/net/context"
2222
"golang.org/x/oauth2"
2323
)
2424

internal/token.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package internal
66

77
import (
8+
"context"
89
"encoding/json"
910
"errors"
1011
"fmt"
@@ -17,7 +18,6 @@ import (
1718
"strings"
1819
"time"
1920

20-
"golang.org/x/net/context"
2121
"golang.org/x/net/context/ctxhttp"
2222
)
2323

internal/token_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
package internal
66

77
import (
8+
"context"
89
"fmt"
910
"io"
1011
"net/http"
1112
"net/http/httptest"
1213
"net/url"
1314
"testing"
14-
15-
"golang.org/x/net/context"
1615
)
1716

1817
func TestRegisterBrokenAuthHeaderProvider(t *testing.T) {

internal/transport.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
package internal
66

77
import (
8+
"context"
89
"net/http"
9-
10-
"golang.org/x/net/context"
1110
)
1211

1312
// HTTPClient is the context key to use with golang.org/x/net/context's

jwt/jwt.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package jwt
1010

1111
import (
12+
"context"
1213
"encoding/json"
1314
"fmt"
1415
"io"
@@ -18,7 +19,6 @@ import (
1819
"strings"
1920
"time"
2021

21-
"golang.org/x/net/context"
2222
"golang.org/x/oauth2"
2323
"golang.org/x/oauth2/internal"
2424
"golang.org/x/oauth2/jws"

oauth2.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ package oauth2 // import "golang.org/x/oauth2"
1010

1111
import (
1212
"bytes"
13+
"context"
1314
"errors"
1415
"net/http"
1516
"net/url"
1617
"strings"
1718
"sync"
1819

19-
"golang.org/x/net/context"
2020
"golang.org/x/oauth2/internal"
2121
)
2222

oauth2_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package oauth2
66

77
import (
8+
"context"
89
"errors"
910
"fmt"
1011
"io/ioutil"
@@ -13,8 +14,6 @@ import (
1314
"net/url"
1415
"testing"
1516
"time"
16-
17-
"golang.org/x/net/context"
1817
)
1918

2019
type mockTransport struct {

token.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
package oauth2
66

77
import (
8+
"context"
89
"fmt"
910
"net/http"
1011
"net/url"
1112
"strconv"
1213
"strings"
1314
"time"
1415

15-
"golang.org/x/net/context"
1616
"golang.org/x/oauth2/internal"
1717
)
1818

0 commit comments

Comments
 (0)