cleanup: no x/net/context (#3120)

Manual change + mockgen
This commit is contained in:
Menghan Li
2019-10-29 13:06:26 -07:00
committed by GitHub
parent a8f166a036
commit 5367efb805
7 changed files with 14 additions and 6 deletions

View File

@ -20,17 +20,18 @@
package main
import (
"context"
"log"
"net"
"os"
"time"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/channelz/service"
pb "google.golang.org/grpc/examples/helloworld/helloworld"
"google.golang.org/grpc/resolver"
"google.golang.org/grpc/resolver/manual"
pb "google.golang.org/grpc/examples/helloworld/helloworld"
)
const (

View File

@ -20,11 +20,11 @@
package main
import (
"context"
"log"
"net"
"time"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/channelz/service"
"google.golang.org/grpc/internal/grpcrand"

View File

@ -4,8 +4,8 @@
package mock_helloworld
import (
context "context"
gomock "github.com/golang/mock/gomock"
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
helloworld "google.golang.org/grpc/examples/helloworld/helloworld"
)

View File

@ -4,8 +4,8 @@
package mock_routeguide
import (
context "context"
gomock "github.com/golang/mock/gomock"
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
routeguide "google.golang.org/grpc/examples/route_guide/routeguide"
metadata "google.golang.org/grpc/metadata"

View File

@ -0,0 +1,3 @@
The pb.go is genenated with an older version of codegen, to test reflection behavior with `grpc.SupportPackageIsVersion3`. DO NOT REGENERATE!
pb.go is manually edited to replace `"golang.org/x/net/context"` with `"context"`.

View File

@ -19,7 +19,8 @@ import fmt "fmt"
import math "math"
import (
context "golang.org/x/net/context"
context "context"
grpc "google.golang.org/grpc"
)

3
vet.sh
View File

@ -76,6 +76,9 @@ fi
(! grep 'func Test[^(]' *_test.go)
(! grep 'func Test[^(]' test/*.go)
# - Do not import x/net/context.
git grep -l 'x/net/context' -- "*.go" 2>&1 | (! grep -v 'orca.pb.go')
# - Do not import math/rand for real library code. Use internal/grpcrand for
# thread safety.
git grep -l '"math/rand"' -- "*.go" 2>&1 | (! grep -v '^examples\|^stress\|grpcrand\|wrr_test')