cleanup: replace "x/net/context" import with "context" (#2439)
diff --git a/balancer.go b/balancer.go
index 5aeb646..a78e702 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 b9a8cbf..1bf46aa 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 6f3f0c8..5f55b27 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 2e15836..789b9c4 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 @@
"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 d77af40..026bbc7 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 2c54025..7b35d11 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 @@
"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 d960d53..7ad0f55 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 @@
"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 1da04e6..57aea9f 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 70d8af7..80c4e2b 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 0dcd916..d36c8e9 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 d9b2eeb..219dcac 100644
--- a/balancer_test.go
+++ b/balancer_test.go
@@ -19,6 +19,7 @@
package grpc
import (
+ "context"
"fmt"
"math"
"strconv"
@@ -26,7 +27,6 @@
"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 e0ce32c..ca07c15 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 5937cf7..9cb329f 100644
--- a/benchmark/benchmain/main.go
+++ b/benchmark/benchmain/main.go
@@ -40,6 +40,7 @@
package main
import (
+ "context"
"encoding/gob"
"errors"
"flag"
@@ -59,7 +60,6 @@
"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 ec9b50b..e9a2723 100644
--- a/benchmark/benchmark.go
+++ b/benchmark/benchmark.go
@@ -24,6 +24,7 @@
package benchmark
import (
+ "context"
"fmt"
"io"
"net"
@@ -31,7 +32,6 @@
"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 fb6f9b6..1cb02ea 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 @@
"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 5839a5c..d5cc44f 100644
--- a/benchmark/latency/latency.go
+++ b/benchmark/latency/latency.go
@@ -23,13 +23,12 @@
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 e1d6c04..1d92192 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 515f6fc..abb5bc9 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 3d2fd61..5933bd3 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 @@
"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 180d79d..100f05d 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 df93640..7800c5d 100644
--- a/call_test.go
+++ b/call_test.go
@@ -19,6 +19,7 @@
package grpc
import (
+ "context"
"fmt"
"io"
"math"
@@ -29,7 +30,6 @@
"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 17a9516..1f72d83 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 894f57d..d90ada0 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 4ec1133..26ef413 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 @@
"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 d6f8b1b..ae75519 100644
--- a/clientconn.go
+++ b/clientconn.go
@@ -1137,8 +1137,8 @@
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 @@
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 b480af9..bf5bbd8 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 56707b3..3f75fe4 100644
--- a/clientconn_test.go
+++ b/clientconn_test.go
@@ -19,6 +19,7 @@
package grpc
import (
+ "context"
"errors"
"fmt"
"math"
@@ -27,7 +28,6 @@
"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 568ef5d..b1d7dbc 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 fba0412..4cb93f1 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 f305071..33fba81 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 574884a..82a1c9c 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 d870a1b..7608f53 100644
--- a/credentials/alts/internal/handshaker/handshaker_test.go
+++ b/credentials/alts/internal/handshaker/handshaker_test.go
@@ -20,10 +20,10 @@
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 49bdcdf..4ed27c6 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 @@
"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 73bb62d..3c7e43d 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 aff58be..2b88dea 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 @@
"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 9b13db5..cb091de 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 b1b5b28..23079c8 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 f6d597a..e0e74d8 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 cc9ec56..445805c 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 4b99ff5..8c44ef0 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 702a3b6..fd0a5b0 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 3966763..358d13b 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 d167c43..343a5ff 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 5135e9d..517065c 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 1ad1c17..29fb737 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 8525cd5..80f3552 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 ececfa7..bd4278e 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 @@
"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 b50fa8c..daccb1e 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 ced95d3..7593aab 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 aa123e4..e15f04c 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 8c2d5c1..894b66b 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 404009d..c86e499 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 1f6ef67..8b73500 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 b75d8cf..6d25f1b 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 @@
"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 41f8af6..f8932b1 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 0b4a3c5..73b41ea 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 @@
"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 d4e2ce3..cf989c7 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 @@
"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 e7e881a..39208b1 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 @@
"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 b9ba5c0..df27403 100644
--- a/internal/transport/http2_server.go
+++ b/internal/transport/http2_server.go
@@ -20,6 +20,7 @@
import (
"bytes"
+ "context"
"errors"
"fmt"
"io"
@@ -31,7 +32,6 @@
"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 3911a29..91b6b95 100644
--- a/internal/transport/transport_test.go
+++ b/internal/transport/transport_test.go
@@ -21,6 +21,7 @@
import (
"bufio"
"bytes"
+ "context"
"encoding/binary"
"errors"
"fmt"
@@ -36,7 +37,6 @@
"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 @@
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 b077610..f3b1028 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 7658a63..2d7da13 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 ee1ae70..7ce970c 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 @@
"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 bd2eaf4..cf6d1b9 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 324f132..f166ffa 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 11ac8da..fd8cd3b 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 317b8b9..e01d219 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 76cc456..14f915d 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 34c6c89..36653b1 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 bda4309..d1e38aa 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 7f8169f..675067f 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 7183ba3..f8c4c1b 100644
--- a/proxy_test.go
+++ b/proxy_test.go
@@ -22,6 +22,7 @@
import (
"bufio"
+ "context"
"io"
"net"
"net/http"
@@ -29,7 +30,6 @@
"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 e2c7416..9078b20 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 @@
"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 56f28a6..f33189f 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 @@
"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 9405584..07673d0 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 @@
"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 0d3fbf5..d705d7a 100644
--- a/server.go
+++ b/server.go
@@ -19,6 +19,7 @@
package grpc
import (
+ "context"
"errors"
"fmt"
"io"
@@ -32,7 +33,6 @@
"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 11ce867..125be01 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 05b384c..dc03731 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 3f13190..84f77da 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 c8a5f23..008d684 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 @@
"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 47aa822..0c266d6 100644
--- a/stream.go
+++ b/stream.go
@@ -19,6 +19,7 @@
package grpc
import (
+ "context"
"errors"
"io"
"math"
@@ -26,12 +27,10 @@
"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 dab8a9d..82febbc 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 @@
"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 70b024b..c9a5c8c 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 22b8fb5..584360f 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 7eb1399..188f5de 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 c204e35..5d89207 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 f56440f..58418f7 100644
--- a/test/creds_test.go
+++ b/test/creds_test.go
@@ -22,9 +22,9 @@
// 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 39e9b00..8fdca90 100644
--- a/test/end2end_test.go
+++ b/test/end2end_test.go
@@ -23,6 +23,7 @@
import (
"bytes"
+ "context"
"crypto/tls"
"errors"
"flag"
@@ -43,7 +44,6 @@
"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 5602358..be44ebb 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 @@
"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 c53b66d..b9a4acf 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 @@
"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 eb9da3a..a13bc08 100755
--- a/vet.sh
+++ b/vet.sh
@@ -87,23 +87,11 @@
# 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