Skip to content

Commit

Permalink
remove golang.org/x/net dependency (#295)
Browse files Browse the repository at this point in the history
* remove golang.org/x/net dependency

The golang.org/x/net/context package is an alias for stdlib context
since go1.7 (see https://go-review.googlesource.com/72570)

This patch replaces all uses of it for stdlib context.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

* rename App Engine context type to remove import aliases

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

---------

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Mar 1, 2023
1 parent 504804f commit a1ae214
Show file tree
Hide file tree
Showing 71 changed files with 248 additions and 284 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ code importing `appengine/datastore` will now need to import `google.golang.org/
Most App Engine services are available with exactly the same API.
A few APIs were cleaned up, and there are some differences:

* `appengine.Context` has been replaced with the `Context` type from `golang.org/x/net/context`.
* `appengine.Context` has been replaced with the `Context` type from `context`.
* Logging methods that were on `appengine.Context` are now functions in `google.golang.org/appengine/log`.
* `appengine.Timeout` has been removed. Use `context.WithTimeout` instead.
* `appengine.Datacenter` now takes a `context.Context` argument.
Expand Down
2 changes: 1 addition & 1 deletion aetest/instance.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package aetest

import (
"context"
"io"
"net/http"
"time"

"golang.org/x/net/context"
"google.golang.org/appengine"
)

Expand Down
2 changes: 1 addition & 1 deletion appengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
package appengine // import "google.golang.org/appengine"

import (
"context"
"net/http"

"github.com/golang/protobuf/proto"
"golang.org/x/net/context"

"google.golang.org/appengine/internal"
)
Expand Down
2 changes: 1 addition & 1 deletion blobstore/blobstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package blobstore // import "google.golang.org/appengine/blobstore"
import (
"bufio"
"bytes"
"context"
"encoding/base64"
"fmt"
"io"
Expand All @@ -23,7 +24,6 @@ import (
"time"

"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"golang.org/x/text/encoding/htmlindex"

"google.golang.org/appengine"
Expand Down
2 changes: 1 addition & 1 deletion blobstore/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
package blobstore

import (
"context"
"errors"
"fmt"
"io"
"os"
"sync"

"github.com/golang/protobuf/proto"
"golang.org/x/net/context"

"google.golang.org/appengine"
"google.golang.org/appengine/internal"
Expand Down
2 changes: 1 addition & 1 deletion capability/capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Example:
package capability // import "google.golang.org/appengine/capability"

import (
"golang.org/x/net/context"
"context"

"google.golang.org/appengine/internal"
"google.golang.org/appengine/log"
Expand Down
3 changes: 1 addition & 2 deletions channel/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ https://cloud.google.com/appengine/docs/deprecations/channel
package channel // import "google.golang.org/appengine/channel"

import (
"context"
"encoding/json"

"golang.org/x/net/context"

"google.golang.org/appengine"
"google.golang.org/appengine/internal"
basepb "google.golang.org/appengine/internal/base"
Expand Down
2 changes: 1 addition & 1 deletion cmd/aefix/ae.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

const (
ctxPackage = "golang.org/x/net/context"
ctxPackage = "context"

newPackageBase = "google.golang.org/"
stutterPackage = false
Expand Down
8 changes: 4 additions & 4 deletions cmd/aefix/ae_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ func f(w http.ResponseWriter, r *http.Request) {
Out: `package foo
import (
"context"
"net/http"
"time"
"golang.org/x/net/context"
"google.golang.org/appengine"
"google.golang.org/appengine/datastore"
"google.golang.org/appengine/log"
Expand Down Expand Up @@ -74,7 +74,7 @@ func LogSomething(c2 appengine.Context) {
Out: `package foo
import (
"golang.org/x/net/context"
"context"
"google.golang.org/appengine/log"
)
Expand Down Expand Up @@ -102,7 +102,7 @@ func f(ctx appengine.Context) {
Out: `package foo
import (
"golang.org/x/net/context"
"context"
"google.golang.org/appengine/taskqueue"
)
Expand Down Expand Up @@ -131,7 +131,7 @@ func f(ctx appengine.Context, w io.Writer) {
Out: `package foo
import (
"golang.org/x/net/context"
"context"
"google.golang.org/appengine"
"io"
)
Expand Down
2 changes: 1 addition & 1 deletion datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
package datastore

import (
"context"
"errors"
"fmt"
"reflect"

"github.com/golang/protobuf/proto"
"golang.org/x/net/context"

"google.golang.org/appengine"
"google.golang.org/appengine/internal"
Expand Down
2 changes: 1 addition & 1 deletion datastore/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package datastore

import (
"bytes"
"context"
"encoding/base64"
"encoding/gob"
"errors"
Expand All @@ -14,7 +15,6 @@ import (
"strings"

"github.com/golang/protobuf/proto"
"golang.org/x/net/context"

"google.golang.org/appengine/internal"
pb "google.golang.org/appengine/internal/datastore"
Expand Down
3 changes: 1 addition & 2 deletions datastore/key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ package datastore

import (
"bytes"
"context"
"encoding/gob"
"encoding/json"
"testing"

"golang.org/x/net/context"

"google.golang.org/appengine/internal"
)

Expand Down
3 changes: 1 addition & 2 deletions datastore/keycompat.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
package datastore

import (
"context"
"sync"

"golang.org/x/net/context"

"google.golang.org/appengine/datastore/internal/cloudkey"
"google.golang.org/appengine/internal"
)
Expand Down
2 changes: 1 addition & 1 deletion datastore/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package datastore

import "golang.org/x/net/context"
import "context"

// Datastore kinds for the metadata entities.
const (
Expand Down
2 changes: 1 addition & 1 deletion datastore/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package datastore

import (
"context"
"encoding/base64"
"errors"
"fmt"
Expand All @@ -13,7 +14,6 @@ import (
"strings"

"github.com/golang/protobuf/proto"
"golang.org/x/net/context"

"google.golang.org/appengine/internal"
pb "google.golang.org/appengine/internal/datastore"
Expand Down
3 changes: 1 addition & 2 deletions datastore/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
package datastore

import (
"context"
"errors"

"golang.org/x/net/context"

"google.golang.org/appengine/internal"
pb "google.golang.org/appengine/internal/datastore"
)
Expand Down
9 changes: 3 additions & 6 deletions delay/delay.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ package delay // import "google.golang.org/appengine/delay"

import (
"bytes"
stdctx "context"
"context"
"encoding/gob"
"errors"
"fmt"
Expand All @@ -72,8 +72,6 @@ import (
"runtime"
"strings"

"golang.org/x/net/context"

"google.golang.org/appengine"
"google.golang.org/appengine/internal"
"google.golang.org/appengine/log"
Expand Down Expand Up @@ -109,12 +107,11 @@ var (

// context keys
headersContextKey contextKey = 0
stdContextType = reflect.TypeOf((*stdctx.Context)(nil)).Elem()
netContextType = reflect.TypeOf((*context.Context)(nil)).Elem()
stdContextType = reflect.TypeOf((*context.Context)(nil)).Elem()
)

func isContext(t reflect.Type) bool {
return t == stdContextType || t == netContextType
return t == stdContextType
}

var modVersionPat = regexp.MustCompile("@v[^/]+")
Expand Down
5 changes: 2 additions & 3 deletions delay/delay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package delay

import (
"bytes"
stdctx "context"
"context"
"encoding/gob"
"errors"
"fmt"
Expand All @@ -18,7 +18,6 @@ import (
"testing"

"github.com/golang/protobuf/proto"
"golang.org/x/net/context"

"google.golang.org/appengine/internal"
"google.golang.org/appengine/taskqueue"
Expand Down Expand Up @@ -107,7 +106,7 @@ var (
})

stdCtxRuns = 0
stdCtxFunc = Func("stdctx", func(c stdctx.Context) {
stdCtxFunc = Func("stdctx", func(c context.Context) {
stdCtxRuns++
})
)
Expand Down
3 changes: 1 addition & 2 deletions demos/guestbook/guestbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
package main

import (
"context"
"html/template"
"net/http"
"time"

"golang.org/x/net/context"

"google.golang.org/appengine"
"google.golang.org/appengine/datastore"
"google.golang.org/appengine/log"
Expand Down
3 changes: 1 addition & 2 deletions file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
package file

import (
"context"
"fmt"

"golang.org/x/net/context"

"google.golang.org/appengine/internal"
aipb "google.golang.org/appengine/internal/app_identity"
)
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ go 1.11

require (
github.com/golang/protobuf v1.5.2
golang.org/x/net v0.0.0-20210525063256-abc453219eb5
golang.org/x/text v0.3.6
)
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
3 changes: 1 addition & 2 deletions identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
package appengine

import (
"context"
"time"

"golang.org/x/net/context"

"google.golang.org/appengine/internal"
pb "google.golang.org/appengine/internal/app_identity"
modpb "google.golang.org/appengine/internal/modules"
Expand Down
3 changes: 1 addition & 2 deletions image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
package image // import "google.golang.org/appengine/image"

import (
"context"
"fmt"
"net/url"

"golang.org/x/net/context"

"google.golang.org/appengine"
"google.golang.org/appengine/internal"
pb "google.golang.org/appengine/internal/image"
Expand Down
2 changes: 1 addition & 1 deletion internal/aetesting/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
package aetesting

import (
"context"
"fmt"
"net/http"
"reflect"
"testing"

"github.com/golang/protobuf/proto"
"golang.org/x/net/context"

"google.golang.org/appengine/internal"
)
Expand Down

0 comments on commit a1ae214

Please sign in to comment.