diff --git a/balancer.go b/balancer.go index 5aeb646d174..a78e702baee 100644 --- a/balancer.go +++ b/balancer.go @@ -19,10 +19,10 @@ package grpc import ( + "context" "net" "sync" - "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" "google.golang.org/grpc/grpclog" diff --git a/balancer/balancer.go b/balancer/balancer.go index b9a8cbf06f3..1bf46aafe6f 100644 --- a/balancer/balancer.go +++ b/balancer/balancer.go @@ -21,11 +21,11 @@ package balancer import ( + "context" "errors" "net" "strings" - "golang.org/x/net/context" "google.golang.org/grpc/connectivity" "google.golang.org/grpc/credentials" "google.golang.org/grpc/metadata" diff --git a/balancer/base/balancer.go b/balancer/base/balancer.go index 6f3f0c86e8a..5f55b274f44 100644 --- a/balancer/base/balancer.go +++ b/balancer/base/balancer.go @@ -19,7 +19,8 @@ package base import ( - "golang.org/x/net/context" + "context" + "google.golang.org/grpc/balancer" "google.golang.org/grpc/connectivity" "google.golang.org/grpc/grpclog" diff --git a/balancer/grpclb/grpclb.go b/balancer/grpclb/grpclb.go index 2e1583641b6..789b9c4337d 100644 --- a/balancer/grpclb/grpclb.go +++ b/balancer/grpclb/grpclb.go @@ -25,6 +25,7 @@ package grpclb import ( + "context" "errors" "strconv" "strings" @@ -32,7 +33,6 @@ import ( "time" durationpb "github.com/golang/protobuf/ptypes/duration" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/balancer" lbpb "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1" diff --git a/balancer/grpclb/grpclb_picker.go b/balancer/grpclb/grpclb_picker.go index d77af401b7c..026bbc7f469 100644 --- a/balancer/grpclb/grpclb_picker.go +++ b/balancer/grpclb/grpclb_picker.go @@ -19,10 +19,10 @@ package grpclb import ( + "context" "sync" "sync/atomic" - "golang.org/x/net/context" "google.golang.org/grpc/balancer" lbpb "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1" "google.golang.org/grpc/codes" diff --git a/balancer/grpclb/grpclb_remote_balancer.go b/balancer/grpclb/grpclb_remote_balancer.go index 2c54025dd5e..7b35d111410 100644 --- a/balancer/grpclb/grpclb_remote_balancer.go +++ b/balancer/grpclb/grpclb_remote_balancer.go @@ -19,6 +19,7 @@ package grpclb import ( + "context" "fmt" "io" "net" @@ -26,7 +27,6 @@ import ( "time" timestamppb "github.com/golang/protobuf/ptypes/timestamp" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/balancer" lbpb "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1" diff --git a/balancer/grpclb/grpclb_test.go b/balancer/grpclb/grpclb_test.go index d960d53cefb..7ad0f556863 100644 --- a/balancer/grpclb/grpclb_test.go +++ b/balancer/grpclb/grpclb_test.go @@ -19,6 +19,7 @@ package grpclb import ( + "context" "errors" "fmt" "io" @@ -31,7 +32,6 @@ import ( "time" durationpb "github.com/golang/protobuf/ptypes/duration" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/balancer" lbgrpc "google.golang.org/grpc/balancer/grpclb/grpc_lb_v1" diff --git a/balancer/roundrobin/roundrobin.go b/balancer/roundrobin/roundrobin.go index 1da04e6937b..57aea9fb4d2 100644 --- a/balancer/roundrobin/roundrobin.go +++ b/balancer/roundrobin/roundrobin.go @@ -22,9 +22,9 @@ package roundrobin import ( + "context" "sync" - "golang.org/x/net/context" "google.golang.org/grpc/balancer" "google.golang.org/grpc/balancer/base" "google.golang.org/grpc/grpclog" diff --git a/balancer/roundrobin/roundrobin_test.go b/balancer/roundrobin/roundrobin_test.go index 70d8af7166c..80c4e2b609a 100644 --- a/balancer/roundrobin/roundrobin_test.go +++ b/balancer/roundrobin/roundrobin_test.go @@ -19,13 +19,13 @@ package roundrobin_test import ( + "context" "fmt" "net" "sync" "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/balancer/roundrobin" "google.golang.org/grpc/codes" diff --git a/balancer_switching_test.go b/balancer_switching_test.go index 0dcd9165c1b..d36c8e96ed6 100644 --- a/balancer_switching_test.go +++ b/balancer_switching_test.go @@ -19,12 +19,12 @@ package grpc import ( + "context" "fmt" "math" "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc/balancer" "google.golang.org/grpc/balancer/roundrobin" "google.golang.org/grpc/connectivity" diff --git a/balancer_test.go b/balancer_test.go index d9b2eebe895..219dcacac17 100644 --- a/balancer_test.go +++ b/balancer_test.go @@ -19,6 +19,7 @@ package grpc import ( + "context" "fmt" "math" "strconv" @@ -26,7 +27,6 @@ import ( "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc/codes" _ "google.golang.org/grpc/grpclog/glogger" "google.golang.org/grpc/internal/leakcheck" diff --git a/balancer_v1_wrapper.go b/balancer_v1_wrapper.go index e0ce32cfb6d..ca07c154b2d 100644 --- a/balancer_v1_wrapper.go +++ b/balancer_v1_wrapper.go @@ -19,10 +19,10 @@ package grpc import ( + "context" "strings" "sync" - "golang.org/x/net/context" "google.golang.org/grpc/balancer" "google.golang.org/grpc/codes" "google.golang.org/grpc/connectivity" diff --git a/benchmark/benchmain/main.go b/benchmark/benchmain/main.go index 5937cf7cee5..9cb329f0be2 100644 --- a/benchmark/benchmain/main.go +++ b/benchmark/benchmain/main.go @@ -40,6 +40,7 @@ Assume there are two result files names as "basePerf" and "curPerf" created by a package main import ( + "context" "encoding/gob" "errors" "flag" @@ -59,7 +60,6 @@ import ( "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc" bm "google.golang.org/grpc/benchmark" testpb "google.golang.org/grpc/benchmark/grpc_testing" diff --git a/benchmark/benchmark.go b/benchmark/benchmark.go index ec9b50b2fe4..e9a2723495e 100644 --- a/benchmark/benchmark.go +++ b/benchmark/benchmark.go @@ -24,6 +24,7 @@ Package benchmark implements the building blocks to setup end-to-end gRPC benchm package benchmark import ( + "context" "fmt" "io" "net" @@ -31,7 +32,6 @@ import ( "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc" testpb "google.golang.org/grpc/benchmark/grpc_testing" "google.golang.org/grpc/benchmark/latency" diff --git a/benchmark/client/main.go b/benchmark/client/main.go index fb6f9b63e32..1cb02ea1659 100644 --- a/benchmark/client/main.go +++ b/benchmark/client/main.go @@ -19,6 +19,7 @@ package main import ( + "context" "flag" "fmt" "os" @@ -27,7 +28,6 @@ import ( "sync" "time" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/benchmark" testpb "google.golang.org/grpc/benchmark/grpc_testing" diff --git a/benchmark/latency/latency.go b/benchmark/latency/latency.go index 5839a5c4429..d5cc44f9b5e 100644 --- a/benchmark/latency/latency.go +++ b/benchmark/latency/latency.go @@ -23,13 +23,12 @@ package latency import ( "bytes" + "context" "encoding/binary" "fmt" "io" "net" "time" - - "golang.org/x/net/context" ) // Dialer is a function matching the signature of net.Dial. diff --git a/benchmark/primitives/context_test.go b/benchmark/primitives/context_test.go index e1d6c043f32..1d92192f343 100644 --- a/benchmark/primitives/context_test.go +++ b/benchmark/primitives/context_test.go @@ -19,10 +19,9 @@ package primitives_test import ( + "context" "testing" "time" - - "golang.org/x/net/context" ) func BenchmarkCancelContextErrNoErr(b *testing.B) { diff --git a/benchmark/worker/benchmark_client.go b/benchmark/worker/benchmark_client.go index 515f6fc5564..abb5bc9928a 100644 --- a/benchmark/worker/benchmark_client.go +++ b/benchmark/worker/benchmark_client.go @@ -19,13 +19,13 @@ package main import ( + "context" "flag" "math" "runtime" "sync" "time" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/benchmark" testpb "google.golang.org/grpc/benchmark/grpc_testing" diff --git a/benchmark/worker/main.go b/benchmark/worker/main.go index 3d2fd6173d9..5933bd3ac7a 100644 --- a/benchmark/worker/main.go +++ b/benchmark/worker/main.go @@ -19,6 +19,7 @@ package main import ( + "context" "flag" "fmt" "io" @@ -29,7 +30,6 @@ import ( "strconv" "time" - "golang.org/x/net/context" "google.golang.org/grpc" testpb "google.golang.org/grpc/benchmark/grpc_testing" "google.golang.org/grpc/codes" diff --git a/call.go b/call.go index 180d79d0656..100f05dc742 100644 --- a/call.go +++ b/call.go @@ -19,7 +19,7 @@ package grpc import ( - "golang.org/x/net/context" + "context" ) // Invoke sends the RPC request on the wire and returns after response is diff --git a/call_test.go b/call_test.go index df9364007a3..7800c5d8499 100644 --- a/call_test.go +++ b/call_test.go @@ -19,6 +19,7 @@ package grpc import ( + "context" "fmt" "io" "math" @@ -29,7 +30,6 @@ import ( "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/internal/leakcheck" "google.golang.org/grpc/internal/transport" diff --git a/channelz/service/service.go b/channelz/service/service.go index 17a95161703..1f72d83cbe0 100644 --- a/channelz/service/service.go +++ b/channelz/service/service.go @@ -22,13 +22,13 @@ package service import ( + "context" "net" "time" "github.com/golang/protobuf/ptypes" durpb "github.com/golang/protobuf/ptypes/duration" wrpb "github.com/golang/protobuf/ptypes/wrappers" - "golang.org/x/net/context" "google.golang.org/grpc" channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1" channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1" diff --git a/channelz/service/service_sktopt_test.go b/channelz/service/service_sktopt_test.go index 894f57d4b17..d90ada0d4bf 100644 --- a/channelz/service/service_sktopt_test.go +++ b/channelz/service/service_sktopt_test.go @@ -26,13 +26,13 @@ package service import ( + "context" "reflect" "strconv" "testing" "github.com/golang/protobuf/ptypes" durpb "github.com/golang/protobuf/ptypes/duration" - "golang.org/x/net/context" "golang.org/x/sys/unix" channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1" "google.golang.org/grpc/internal/channelz" diff --git a/channelz/service/service_test.go b/channelz/service/service_test.go index 4ec1133cc5e..26ef41314c2 100644 --- a/channelz/service/service_test.go +++ b/channelz/service/service_test.go @@ -19,6 +19,7 @@ package service import ( + "context" "fmt" "net" "reflect" @@ -28,7 +29,6 @@ import ( "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes" - "golang.org/x/net/context" channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1" "google.golang.org/grpc/connectivity" "google.golang.org/grpc/credentials" diff --git a/clientconn.go b/clientconn.go index d6f8b1b8936..ae755197e7d 100644 --- a/clientconn.go +++ b/clientconn.go @@ -1137,8 +1137,8 @@ func (ac *addrConn) createTransport(backoffNum int, addr resolver.Address, copts ac.mu.Unlock() } - // Do not cancel in the success path because of this issue in Go1.6: https://github.com/golang/go/issues/15078. connectCtx, cancel := context.WithDeadline(ac.ctx, connectDeadline) + defer cancel() if channelz.IsOn() { copts.ChannelzParentID = ac.channelzID } @@ -1183,7 +1183,6 @@ func (ac *addrConn) createTransport(backoffNum int, addr resolver.Address, copts if err != nil { // newTr is either nil, or closed. - cancel() ac.cc.blockingpicker.updateConnectionError(err) ac.mu.Lock() if ac.state == connectivity.Shutdown { diff --git a/clientconn_state_transition_test.go b/clientconn_state_transition_test.go index b480af9e7d9..bf5bbd8896d 100644 --- a/clientconn_state_transition_test.go +++ b/clientconn_state_transition_test.go @@ -19,13 +19,13 @@ package grpc import ( + "context" "net" "sync" "sync/atomic" "testing" "time" - "golang.org/x/net/context" "golang.org/x/net/http2" "google.golang.org/grpc/balancer" "google.golang.org/grpc/connectivity" diff --git a/clientconn_test.go b/clientconn_test.go index 56707b398d4..3f75fe45403 100644 --- a/clientconn_test.go +++ b/clientconn_test.go @@ -19,6 +19,7 @@ package grpc import ( + "context" "errors" "fmt" "math" @@ -27,7 +28,6 @@ import ( "testing" "time" - "golang.org/x/net/context" "golang.org/x/net/http2" "google.golang.org/grpc/connectivity" "google.golang.org/grpc/credentials" diff --git a/connectivity/connectivity.go b/connectivity/connectivity.go index 568ef5dc68b..b1d7dbc5470 100644 --- a/connectivity/connectivity.go +++ b/connectivity/connectivity.go @@ -22,7 +22,8 @@ package connectivity import ( - "golang.org/x/net/context" + "context" + "google.golang.org/grpc/grpclog" ) diff --git a/credentials/alts/alts.go b/credentials/alts/alts.go index fba041268ff..4cb93f16473 100644 --- a/credentials/alts/alts.go +++ b/credentials/alts/alts.go @@ -24,13 +24,13 @@ package alts import ( + "context" "errors" "fmt" "net" "sync" "time" - "golang.org/x/net/context" "google.golang.org/grpc/credentials" core "google.golang.org/grpc/credentials/alts/internal" "google.golang.org/grpc/credentials/alts/internal/handshaker" diff --git a/credentials/alts/internal/common.go b/credentials/alts/internal/common.go index f30507180ed..33fba81239a 100644 --- a/credentials/alts/internal/common.go +++ b/credentials/alts/internal/common.go @@ -22,9 +22,9 @@ package internal import ( + "context" "net" - "golang.org/x/net/context" "google.golang.org/grpc/credentials" ) diff --git a/credentials/alts/internal/handshaker/handshaker.go b/credentials/alts/internal/handshaker/handshaker.go index 574884ad1c5..82a1c9c58b5 100644 --- a/credentials/alts/internal/handshaker/handshaker.go +++ b/credentials/alts/internal/handshaker/handshaker.go @@ -20,13 +20,13 @@ package handshaker import ( + "context" "errors" "fmt" "io" "net" "sync" - "golang.org/x/net/context" grpc "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" diff --git a/credentials/alts/internal/handshaker/handshaker_test.go b/credentials/alts/internal/handshaker/handshaker_test.go index d870a1b3e58..7608f53b788 100644 --- a/credentials/alts/internal/handshaker/handshaker_test.go +++ b/credentials/alts/internal/handshaker/handshaker_test.go @@ -20,10 +20,10 @@ package handshaker import ( "bytes" + "context" "testing" "time" - "golang.org/x/net/context" grpc "google.golang.org/grpc" core "google.golang.org/grpc/credentials/alts/internal" altspb "google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp" diff --git a/credentials/alts/utils.go b/credentials/alts/utils.go index 49bdcdf79ba..4ed27c605b6 100644 --- a/credentials/alts/utils.go +++ b/credentials/alts/utils.go @@ -19,6 +19,7 @@ package alts import ( + "context" "errors" "fmt" "io" @@ -30,7 +31,6 @@ import ( "runtime" "strings" - "golang.org/x/net/context" "google.golang.org/grpc/peer" ) diff --git a/credentials/alts/utils_test.go b/credentials/alts/utils_test.go index 73bb62d8d65..3c7e43db14a 100644 --- a/credentials/alts/utils_test.go +++ b/credentials/alts/utils_test.go @@ -19,11 +19,11 @@ package alts import ( + "context" "io" "strings" "testing" - "golang.org/x/net/context" altspb "google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp" "google.golang.org/grpc/peer" ) diff --git a/credentials/credentials.go b/credentials/credentials.go index aff58bee1ab..2b88deadbba 100644 --- a/credentials/credentials.go +++ b/credentials/credentials.go @@ -23,6 +23,7 @@ package credentials // import "google.golang.org/grpc/credentials" import ( + "context" "crypto/tls" "crypto/x509" "errors" @@ -32,7 +33,6 @@ import ( "strings" "github.com/golang/protobuf/proto" - "golang.org/x/net/context" ) // alpnProtoStr are the specified application level protocols for gRPC. diff --git a/credentials/credentials_test.go b/credentials/credentials_test.go index 9b13db51d43..cb091de0809 100644 --- a/credentials/credentials_test.go +++ b/credentials/credentials_test.go @@ -19,11 +19,11 @@ package credentials import ( + "context" "crypto/tls" "net" "testing" - "golang.org/x/net/context" "google.golang.org/grpc/testdata" ) diff --git a/credentials/google/google.go b/credentials/google/google.go index b1b5b2815ba..23079c80a67 100644 --- a/credentials/google/google.go +++ b/credentials/google/google.go @@ -20,10 +20,10 @@ package google import ( + "context" "fmt" "time" - "golang.org/x/net/context" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/alts" "google.golang.org/grpc/credentials/oauth" diff --git a/credentials/oauth/oauth.go b/credentials/oauth/oauth.go index f6d597a14fe..e0e74d8153c 100644 --- a/credentials/oauth/oauth.go +++ b/credentials/oauth/oauth.go @@ -20,11 +20,11 @@ package oauth import ( + "context" "fmt" "io/ioutil" "sync" - "golang.org/x/net/context" "golang.org/x/oauth2" "golang.org/x/oauth2/google" "golang.org/x/oauth2/jwt" diff --git a/dialoptions.go b/dialoptions.go index cc9ec56b9af..445805cc6a7 100644 --- a/dialoptions.go +++ b/dialoptions.go @@ -19,11 +19,11 @@ package grpc import ( + "context" "fmt" "net" "time" - "golang.org/x/net/context" "google.golang.org/grpc/balancer" "google.golang.org/grpc/credentials" "google.golang.org/grpc/internal" diff --git a/examples/helloworld/greeter_client/main.go b/examples/helloworld/greeter_client/main.go index 4b99ff5a706..8c44ef03ad8 100644 --- a/examples/helloworld/greeter_client/main.go +++ b/examples/helloworld/greeter_client/main.go @@ -19,11 +19,11 @@ package main import ( + "context" "log" "os" "time" - "golang.org/x/net/context" "google.golang.org/grpc" pb "google.golang.org/grpc/examples/helloworld/helloworld" ) diff --git a/examples/helloworld/greeter_server/main.go b/examples/helloworld/greeter_server/main.go index 702a3b6170f..fd0a5b00d29 100644 --- a/examples/helloworld/greeter_server/main.go +++ b/examples/helloworld/greeter_server/main.go @@ -21,10 +21,10 @@ package main import ( + "context" "log" "net" - "golang.org/x/net/context" "google.golang.org/grpc" pb "google.golang.org/grpc/examples/helloworld/helloworld" "google.golang.org/grpc/reflection" diff --git a/examples/helloworld/mock_helloworld/hw_mock_test.go b/examples/helloworld/mock_helloworld/hw_mock_test.go index 3966763313e..358d13bda4d 100644 --- a/examples/helloworld/mock_helloworld/hw_mock_test.go +++ b/examples/helloworld/mock_helloworld/hw_mock_test.go @@ -19,13 +19,13 @@ package mock_helloworld_test import ( + "context" "fmt" "testing" "time" "github.com/golang/mock/gomock" "github.com/golang/protobuf/proto" - "golang.org/x/net/context" helloworld "google.golang.org/grpc/examples/helloworld/helloworld" hwmock "google.golang.org/grpc/examples/helloworld/mock_helloworld" ) diff --git a/examples/oauth/client/main.go b/examples/oauth/client/main.go index d167c43e623..343a5ff7edf 100644 --- a/examples/oauth/client/main.go +++ b/examples/oauth/client/main.go @@ -20,11 +20,11 @@ package main import ( + "context" "crypto/tls" "log" "time" - "golang.org/x/net/context" "golang.org/x/oauth2" "google.golang.org/grpc" "google.golang.org/grpc/credentials" diff --git a/examples/oauth/server/main.go b/examples/oauth/server/main.go index 5135e9dcc71..517065c5cc6 100644 --- a/examples/oauth/server/main.go +++ b/examples/oauth/server/main.go @@ -21,12 +21,12 @@ package main import ( + "context" "crypto/tls" "log" "net" "strings" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" diff --git a/examples/route_guide/client/client.go b/examples/route_guide/client/client.go index 1ad1c179343..29fb7378514 100644 --- a/examples/route_guide/client/client.go +++ b/examples/route_guide/client/client.go @@ -23,13 +23,13 @@ package main import ( + "context" "flag" "io" "log" "math/rand" "time" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/credentials" pb "google.golang.org/grpc/examples/route_guide/routeguide" diff --git a/examples/route_guide/mock_routeguide/rg_mock_test.go b/examples/route_guide/mock_routeguide/rg_mock_test.go index 8525cd5fd2f..80f35524ddd 100644 --- a/examples/route_guide/mock_routeguide/rg_mock_test.go +++ b/examples/route_guide/mock_routeguide/rg_mock_test.go @@ -19,13 +19,13 @@ package mock_routeguide_test import ( + "context" "fmt" "testing" "time" "github.com/golang/mock/gomock" "github.com/golang/protobuf/proto" - "golang.org/x/net/context" rgmock "google.golang.org/grpc/examples/route_guide/mock_routeguide" rgpb "google.golang.org/grpc/examples/route_guide/routeguide" ) diff --git a/examples/route_guide/server/server.go b/examples/route_guide/server/server.go index ececfa7e59c..bd4278edaef 100644 --- a/examples/route_guide/server/server.go +++ b/examples/route_guide/server/server.go @@ -25,6 +25,7 @@ package main import ( + "context" "encoding/json" "flag" "fmt" @@ -36,7 +37,6 @@ import ( "sync" "time" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/credentials" diff --git a/examples/rpc_errors/client/main.go b/examples/rpc_errors/client/main.go index b50fa8ce964..daccb1ef2e3 100644 --- a/examples/rpc_errors/client/main.go +++ b/examples/rpc_errors/client/main.go @@ -19,11 +19,11 @@ package main import ( + "context" "log" "os" "time" - "golang.org/x/net/context" epb "google.golang.org/genproto/googleapis/rpc/errdetails" "google.golang.org/grpc" pb "google.golang.org/grpc/examples/helloworld/helloworld" diff --git a/examples/rpc_errors/server/main.go b/examples/rpc_errors/server/main.go index ced95d3eff1..7593aabd10c 100644 --- a/examples/rpc_errors/server/main.go +++ b/examples/rpc_errors/server/main.go @@ -19,12 +19,12 @@ package main import ( + "context" "fmt" "log" "net" "sync" - "golang.org/x/net/context" epb "google.golang.org/genproto/googleapis/rpc/errdetails" "google.golang.org/grpc" "google.golang.org/grpc/codes" diff --git a/health/client.go b/health/client.go index aa123e4e24e..e15f04c229c 100644 --- a/health/client.go +++ b/health/client.go @@ -19,11 +19,11 @@ package health import ( + "context" "fmt" "io" "time" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" healthpb "google.golang.org/grpc/health/grpc_health_v1" diff --git a/health/client_test.go b/health/client_test.go index 8c2d5c104c8..894b66ba7fc 100644 --- a/health/client_test.go +++ b/health/client_test.go @@ -19,12 +19,11 @@ package health import ( + "context" "errors" "reflect" "testing" "time" - - "golang.org/x/net/context" ) func TestClientHealthCheckBackoff(t *testing.T) { diff --git a/health/server.go b/health/server.go index 404009d49ed..c86e4998897 100644 --- a/health/server.go +++ b/health/server.go @@ -23,9 +23,9 @@ package health import ( + "context" "sync" - "golang.org/x/net/context" "google.golang.org/grpc/codes" healthgrpc "google.golang.org/grpc/health/grpc_health_v1" healthpb "google.golang.org/grpc/health/grpc_health_v1" diff --git a/interceptor.go b/interceptor.go index 1f6ef678035..8b7350022ad 100644 --- a/interceptor.go +++ b/interceptor.go @@ -19,7 +19,7 @@ package grpc import ( - "golang.org/x/net/context" + "context" ) // UnaryInvoker is called by UnaryClientInterceptor to complete RPCs. diff --git a/internal/binarylog/binarylog_end2end_test.go b/internal/binarylog/binarylog_end2end_test.go index b75d8cfa336..6d25f1be627 100644 --- a/internal/binarylog/binarylog_end2end_test.go +++ b/internal/binarylog/binarylog_end2end_test.go @@ -19,6 +19,7 @@ package binarylog_test import ( + "context" "fmt" "io" "net" @@ -29,7 +30,6 @@ import ( "github.com/golang/protobuf/proto" - "golang.org/x/net/context" "google.golang.org/grpc" pb "google.golang.org/grpc/binarylog/grpc_binarylog_v1" "google.golang.org/grpc/grpclog" diff --git a/internal/internal.go b/internal/internal.go index 41f8af67810..f8932b1d86a 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -20,7 +20,7 @@ // symbols to avoid circular dependencies. package internal -import "golang.org/x/net/context" +import "context" var ( // WithContextDialer is exported by clientconn.go diff --git a/internal/transport/handler_server.go b/internal/transport/handler_server.go index 0b4a3c5e352..73b41ea7e0b 100644 --- a/internal/transport/handler_server.go +++ b/internal/transport/handler_server.go @@ -24,6 +24,7 @@ package transport import ( + "context" "errors" "fmt" "io" @@ -34,7 +35,6 @@ import ( "time" "github.com/golang/protobuf/proto" - "golang.org/x/net/context" "golang.org/x/net/http2" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" diff --git a/internal/transport/handler_server_test.go b/internal/transport/handler_server_test.go index d4e2ce3b9cc..cf989c76e96 100644 --- a/internal/transport/handler_server_test.go +++ b/internal/transport/handler_server_test.go @@ -19,6 +19,7 @@ package transport import ( + "context" "errors" "fmt" "io" @@ -32,7 +33,6 @@ import ( "github.com/golang/protobuf/proto" dpb "github.com/golang/protobuf/ptypes/duration" - "golang.org/x/net/context" epb "google.golang.org/genproto/googleapis/rpc/errdetails" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" diff --git a/internal/transport/http2_client.go b/internal/transport/http2_client.go index e7e881a2230..39208b146e0 100644 --- a/internal/transport/http2_client.go +++ b/internal/transport/http2_client.go @@ -19,6 +19,7 @@ package transport import ( + "context" "fmt" "io" "math" @@ -29,7 +30,6 @@ import ( "sync/atomic" "time" - "golang.org/x/net/context" "golang.org/x/net/http2" "golang.org/x/net/http2/hpack" diff --git a/internal/transport/http2_server.go b/internal/transport/http2_server.go index b9ba5c0daf6..df2740398bd 100644 --- a/internal/transport/http2_server.go +++ b/internal/transport/http2_server.go @@ -20,6 +20,7 @@ package transport import ( "bytes" + "context" "errors" "fmt" "io" @@ -31,7 +32,6 @@ import ( "time" "github.com/golang/protobuf/proto" - "golang.org/x/net/context" "golang.org/x/net/http2" "golang.org/x/net/http2/hpack" diff --git a/internal/transport/transport_test.go b/internal/transport/transport_test.go index 3911a2925d1..91b6b95fae8 100644 --- a/internal/transport/transport_test.go +++ b/internal/transport/transport_test.go @@ -21,6 +21,7 @@ package transport import ( "bufio" "bytes" + "context" "encoding/binary" "errors" "fmt" @@ -36,7 +37,6 @@ import ( "testing" "time" - "golang.org/x/net/context" "golang.org/x/net/http2" "golang.org/x/net/http2/hpack" "google.golang.org/grpc/codes" @@ -2028,13 +2028,10 @@ func setUpHTTPStatusTest(t *testing.T, httpStatus int, wh writeHeaders) (*Stream wh: wh, } server.start(t, lis) - // TODO(deklerk): we can `defer cancel()` here after we drop Go 1.6 support. Until then, - // doing a `defer cancel()` could cause the dialer to become broken: - // https://github.com/golang/go/issues/15078, https://github.com/golang/go/issues/15035 connectCtx, cancel := context.WithDeadline(context.Background(), time.Now().Add(2*time.Second)) + defer cancel() client, err := newHTTP2Client(connectCtx, context.Background(), TargetInfo{Addr: lis.Addr().String()}, ConnectOptions{}, func() {}, func(GoAwayReason) {}, func() {}) if err != nil { - cancel() // Do not cancel in success path. lis.Close() t.Fatalf("Error creating client. Err: %v", err) } diff --git a/interop/alts/client/client.go b/interop/alts/client/client.go index b07761076be..f3b1028bfbf 100644 --- a/interop/alts/client/client.go +++ b/interop/alts/client/client.go @@ -20,10 +20,10 @@ package main import ( + "context" "flag" "time" - "golang.org/x/net/context" grpc "google.golang.org/grpc" "google.golang.org/grpc/credentials/alts" "google.golang.org/grpc/grpclog" diff --git a/interop/http2/negative_http2_client.go b/interop/http2/negative_http2_client.go index 7658a6342dc..2d7da138f34 100644 --- a/interop/http2/negative_http2_client.go +++ b/interop/http2/negative_http2_client.go @@ -24,13 +24,13 @@ package main import ( + "context" "flag" "net" "strconv" "sync" "time" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" diff --git a/interop/test_utils.go b/interop/test_utils.go index ee1ae70324b..7ce970cc1ae 100644 --- a/interop/test_utils.go +++ b/interop/test_utils.go @@ -21,6 +21,7 @@ package interop import ( + "context" "fmt" "io" "io/ioutil" @@ -28,7 +29,6 @@ import ( "time" "github.com/golang/protobuf/proto" - "golang.org/x/net/context" "golang.org/x/oauth2" "golang.org/x/oauth2/google" "google.golang.org/grpc" diff --git a/metadata/metadata.go b/metadata/metadata.go index bd2eaf40837..cf6d1b94781 100644 --- a/metadata/metadata.go +++ b/metadata/metadata.go @@ -22,10 +22,9 @@ package metadata // import "google.golang.org/grpc/metadata" import ( + "context" "fmt" "strings" - - "golang.org/x/net/context" ) // DecodeKeyValue returns k, v, nil. diff --git a/metadata/metadata_test.go b/metadata/metadata_test.go index 324f1323fc5..f166ffaf76b 100644 --- a/metadata/metadata_test.go +++ b/metadata/metadata_test.go @@ -19,11 +19,10 @@ package metadata import ( + "context" "reflect" "strconv" "testing" - - "golang.org/x/net/context" ) func TestPairsMD(t *testing.T) { diff --git a/naming/dns_resolver.go b/naming/dns_resolver.go index 11ac8dac475..fd8cd3b5a4f 100644 --- a/naming/dns_resolver.go +++ b/naming/dns_resolver.go @@ -19,13 +19,13 @@ package naming import ( + "context" "errors" "fmt" "net" "strconv" "time" - "golang.org/x/net/context" "google.golang.org/grpc/grpclog" ) diff --git a/peer/peer.go b/peer/peer.go index 317b8b9d09a..e01d219ffbc 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -21,9 +21,9 @@ package peer import ( + "context" "net" - "golang.org/x/net/context" "google.golang.org/grpc/credentials" ) diff --git a/picker_wrapper.go b/picker_wrapper.go index 76cc456aa7e..14f915d6768 100644 --- a/picker_wrapper.go +++ b/picker_wrapper.go @@ -19,10 +19,10 @@ package grpc import ( + "context" "io" "sync" - "golang.org/x/net/context" "google.golang.org/grpc/balancer" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" diff --git a/picker_wrapper_test.go b/picker_wrapper_test.go index 34c6c89154f..36653b12e7e 100644 --- a/picker_wrapper_test.go +++ b/picker_wrapper_test.go @@ -19,12 +19,12 @@ package grpc import ( + "context" "fmt" "sync/atomic" "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc/balancer" "google.golang.org/grpc/connectivity" _ "google.golang.org/grpc/grpclog/glogger" diff --git a/pickfirst.go b/pickfirst.go index bda4309c03a..d1e38aad778 100644 --- a/pickfirst.go +++ b/pickfirst.go @@ -19,7 +19,8 @@ package grpc import ( - "golang.org/x/net/context" + "context" + "google.golang.org/grpc/balancer" "google.golang.org/grpc/connectivity" "google.golang.org/grpc/grpclog" diff --git a/pickfirst_test.go b/pickfirst_test.go index 7f8169f19fe..675067fd9d4 100644 --- a/pickfirst_test.go +++ b/pickfirst_test.go @@ -19,12 +19,12 @@ package grpc import ( + "context" "math" "sync" "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/internal/leakcheck" "google.golang.org/grpc/resolver" diff --git a/proxy_test.go b/proxy_test.go index 7183ba34255..f8c4c1b0845 100644 --- a/proxy_test.go +++ b/proxy_test.go @@ -22,6 +22,7 @@ package grpc import ( "bufio" + "context" "io" "net" "net/http" @@ -29,7 +30,6 @@ import ( "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc/internal/leakcheck" ) diff --git a/reflection/serverreflection_test.go b/reflection/serverreflection_test.go index e2c7416970d..9078b2055ce 100644 --- a/reflection/serverreflection_test.go +++ b/reflection/serverreflection_test.go @@ -24,6 +24,7 @@ package reflection import ( + "context" "fmt" "net" "reflect" @@ -32,7 +33,6 @@ import ( "github.com/golang/protobuf/proto" dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" - "golang.org/x/net/context" "google.golang.org/grpc" rpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" pb "google.golang.org/grpc/reflection/grpc_testing" diff --git a/resolver/dns/dns_resolver.go b/resolver/dns/dns_resolver.go index 56f28a647da..f33189fede2 100644 --- a/resolver/dns/dns_resolver.go +++ b/resolver/dns/dns_resolver.go @@ -21,6 +21,7 @@ package dns import ( + "context" "encoding/json" "errors" "fmt" @@ -31,7 +32,6 @@ import ( "sync" "time" - "golang.org/x/net/context" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/internal/backoff" "google.golang.org/grpc/internal/grpcrand" diff --git a/resolver/dns/dns_resolver_test.go b/resolver/dns/dns_resolver_test.go index 940558414e0..07673d0daec 100644 --- a/resolver/dns/dns_resolver_test.go +++ b/resolver/dns/dns_resolver_test.go @@ -19,6 +19,7 @@ package dns import ( + "context" "errors" "fmt" "net" @@ -28,7 +29,6 @@ import ( "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc/internal/leakcheck" "google.golang.org/grpc/resolver" ) diff --git a/server.go b/server.go index 0d3fbf59fd9..d705d7a80cd 100644 --- a/server.go +++ b/server.go @@ -19,6 +19,7 @@ package grpc import ( + "context" "errors" "fmt" "io" @@ -32,7 +33,6 @@ import ( "sync/atomic" "time" - "golang.org/x/net/context" "golang.org/x/net/trace" "google.golang.org/grpc/codes" diff --git a/server_test.go b/server_test.go index 11ce8673379..125be01c57b 100644 --- a/server_test.go +++ b/server_test.go @@ -19,13 +19,13 @@ package grpc import ( + "context" "net" "reflect" "strings" "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc/internal/leakcheck" "google.golang.org/grpc/internal/transport" ) diff --git a/stats/handlers.go b/stats/handlers.go index 05b384c6931..dc03731e45e 100644 --- a/stats/handlers.go +++ b/stats/handlers.go @@ -19,9 +19,8 @@ package stats import ( + "context" "net" - - "golang.org/x/net/context" ) // ConnTagInfo defines the relevant information needed by connection context tagger. diff --git a/stats/stats.go b/stats/stats.go index 3f13190a0ac..84f77dafa58 100644 --- a/stats/stats.go +++ b/stats/stats.go @@ -24,10 +24,9 @@ package stats // import "google.golang.org/grpc/stats" import ( + "context" "net" "time" - - "golang.org/x/net/context" ) // RPCStats contains stats information about RPCs. diff --git a/stats/stats_test.go b/stats/stats_test.go index c8a5f239776..008d684c102 100644 --- a/stats/stats_test.go +++ b/stats/stats_test.go @@ -19,6 +19,7 @@ package stats_test import ( + "context" "fmt" "io" "net" @@ -28,7 +29,6 @@ import ( "time" "github.com/golang/protobuf/proto" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/metadata" "google.golang.org/grpc/stats" diff --git a/stream.go b/stream.go index 47aa822c2d2..0c266d6f9a3 100644 --- a/stream.go +++ b/stream.go @@ -19,6 +19,7 @@ package grpc import ( + "context" "errors" "io" "math" @@ -26,12 +27,10 @@ import ( "sync" "time" - "google.golang.org/grpc/connectivity" - - "golang.org/x/net/context" "golang.org/x/net/trace" "google.golang.org/grpc/balancer" "google.golang.org/grpc/codes" + "google.golang.org/grpc/connectivity" "google.golang.org/grpc/encoding" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/internal/binarylog" diff --git a/stress/client/main.go b/stress/client/main.go index dab8a9d743a..82febbc242a 100644 --- a/stress/client/main.go +++ b/stress/client/main.go @@ -22,6 +22,7 @@ package main import ( + "context" "flag" "fmt" "math/rand" @@ -31,7 +32,6 @@ import ( "sync" "time" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" diff --git a/stress/metrics_client/main.go b/stress/metrics_client/main.go index 70b024b635c..c9a5c8c559f 100644 --- a/stress/metrics_client/main.go +++ b/stress/metrics_client/main.go @@ -19,11 +19,11 @@ package main import ( + "context" "flag" "fmt" "io" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/grpclog" metricspb "google.golang.org/grpc/stress/grpc_testing" diff --git a/tap/tap.go b/tap/tap.go index 22b8fb50dea..584360f681b 100644 --- a/tap/tap.go +++ b/tap/tap.go @@ -21,7 +21,7 @@ package tap import ( - "golang.org/x/net/context" + "context" ) // Info defines the relevant information needed by the handles. diff --git a/test/balancer_test.go b/test/balancer_test.go index 7eb139959fa..188f5debec7 100644 --- a/test/balancer_test.go +++ b/test/balancer_test.go @@ -19,11 +19,11 @@ package test import ( + "context" "reflect" "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/balancer" "google.golang.org/grpc/connectivity" diff --git a/test/channelz_test.go b/test/channelz_test.go index c204e35f1ec..5d892077686 100644 --- a/test/channelz_test.go +++ b/test/channelz_test.go @@ -19,13 +19,13 @@ package test import ( + "context" "fmt" "net" "sync" "testing" "time" - "golang.org/x/net/context" "golang.org/x/net/http2" "google.golang.org/grpc" _ "google.golang.org/grpc/balancer/grpclb" diff --git a/test/creds_test.go b/test/creds_test.go index f56440fa2e1..58418f78211 100644 --- a/test/creds_test.go +++ b/test/creds_test.go @@ -22,9 +22,9 @@ package test // tests to this file. import ( + "context" "testing" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/internal/leakcheck" diff --git a/test/end2end_test.go b/test/end2end_test.go index 39e9b00f811..8fdca906a29 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -23,6 +23,7 @@ package test import ( "bytes" + "context" "crypto/tls" "errors" "flag" @@ -43,7 +44,6 @@ import ( "github.com/golang/protobuf/proto" anypb "github.com/golang/protobuf/ptypes/any" - "golang.org/x/net/context" "golang.org/x/net/http2" spb "google.golang.org/genproto/googleapis/rpc/status" "google.golang.org/grpc" diff --git a/test/gracefulstop_test.go b/test/gracefulstop_test.go index 560235859a1..be44ebb0052 100644 --- a/test/gracefulstop_test.go +++ b/test/gracefulstop_test.go @@ -19,6 +19,7 @@ package test import ( + "context" "fmt" "io" "net" @@ -26,7 +27,6 @@ import ( "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/internal/leakcheck" diff --git a/test/retry_test.go b/test/retry_test.go index c53b66db6ea..b9a4acff51e 100644 --- a/test/retry_test.go +++ b/test/retry_test.go @@ -19,6 +19,7 @@ package test import ( + "context" "fmt" "io" "os" @@ -29,7 +30,6 @@ import ( "time" "github.com/golang/protobuf/proto" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/internal/envconfig" diff --git a/vet.sh b/vet.sh index eb9da3ac949..a13bc0817f0 100755 --- a/vet.sh +++ b/vet.sh @@ -87,23 +87,11 @@ git ls-files "*.go" | (! xargs grep "\(import \|^\s*\)\"github.com/golang/protob # TODO: Remove when we drop Go 1.10 support go list -f {{.Dir}} ./... | xargs go run test/go_vet/vet.go -# - gofmt, goimports, golint (with exceptions for generated code). +# - gofmt, goimports, golint (with exceptions for generated code), go vet. gofmt -s -d -l . 2>&1 | fail_on_output goimports -l . 2>&1 | fail_on_output golint ./... 2>&1 | (! grep -vE "(_mock|\.pb)\.go:") - -# - go vet -# TODO: Remove from here to "END TODO" and use simply "go tool vet -all ." when -# context is imported directly and 1.6 support is dropped. -# Rewrite golang.org/x/net/context -> context imports (see grpc/grpc-go#1484). -git ls-files "*.go" | xargs sed -i 's:"golang.org/x/net/context":"context":' -set +o pipefail # vet exits with non-zero error if issues are found -go tool vet -all . 2>&1 | \ - grep -vE 'clientconn.go:.*cancel (function|var)' | \ - (! grep -vE '.*transport_test.go:.*cancel') -set -o pipefail -git reset --hard HEAD -# END TODO +go tool vet -all . # - Check that generated proto files are up to date. if [[ -z "${VET_SKIP_PROTO}" ]]; then