.*: revive from unused_parameters (#7577)

This commit is contained in:
Arvind Bright 2024-08-30 10:41:30 -07:00 committed by GitHub
parent 845f62caf4
commit 8320224ff0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
147 changed files with 426 additions and 427 deletions

View File

@ -36,7 +36,7 @@ type baseBuilder struct {
config Config config Config
} }
func (bb *baseBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions) balancer.Balancer { func (bb *baseBuilder) Build(cc balancer.ClientConn, _ balancer.BuildOptions) balancer.Balancer {
bal := &baseBalancer{ bal := &baseBalancer{
cc: cc, cc: cc,
pickerBuilder: bb.pickerBuilder, pickerBuilder: bb.pickerBuilder,
@ -259,6 +259,6 @@ type errPicker struct {
err error // Pick() always returns this err. err error // Pick() always returns this err.
} }
func (p *errPicker) Pick(info balancer.PickInfo) (balancer.PickResult, error) { func (p *errPicker) Pick(balancer.PickInfo) (balancer.PickResult, error) {
return balancer.PickResult{}, p.err return balancer.PickResult{}, p.err
} }

View File

@ -44,7 +44,7 @@ type testSubConn struct {
updateState func(balancer.SubConnState) updateState func(balancer.SubConnState)
} }
func (sc *testSubConn) UpdateAddresses(addresses []resolver.Address) {} func (sc *testSubConn) UpdateAddresses([]resolver.Address) {}
func (sc *testSubConn) Connect() {} func (sc *testSubConn) Connect() {}
@ -88,7 +88,7 @@ func TestBaseBalancerReserveAttributes(t *testing.T) {
} }
pickBuilder := &testPickBuilder{validate: v} pickBuilder := &testPickBuilder{validate: v}
b := (&baseBuilder{pickerBuilder: pickBuilder}).Build(&testClientConn{ b := (&baseBuilder{pickerBuilder: pickBuilder}).Build(&testClientConn{
newSubConn: func(addrs []resolver.Address, opts balancer.NewSubConnOptions) (balancer.SubConn, error) { newSubConn: func(_ []resolver.Address, opts balancer.NewSubConnOptions) (balancer.SubConn, error) {
return &testSubConn{updateState: opts.StateListener}, nil return &testSubConn{updateState: opts.StateListener}, nil
}, },
}, balancer.BuildOptions{}).(*baseBalancer) }, balancer.BuildOptions{}).(*baseBalancer)

View File

@ -165,7 +165,7 @@ func (es *endpointSharding) ResolverError(err error) {
} }
} }
func (es *endpointSharding) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) { func (es *endpointSharding) UpdateSubConnState(balancer.SubConn, balancer.SubConnState) {
// UpdateSubConnState is deprecated. // UpdateSubConnState is deprecated.
} }

View File

@ -79,7 +79,7 @@ func (fakePetioleBuilder) Build(cc balancer.ClientConn, opts balancer.BuildOptio
return fp return fp
} }
func (fakePetioleBuilder) ParseConfig(s json.RawMessage) (serviceconfig.LoadBalancingConfig, error) { func (fakePetioleBuilder) ParseConfig(json.RawMessage) (serviceconfig.LoadBalancingConfig, error) {
return nil, nil return nil, nil
} }

View File

@ -126,7 +126,7 @@ func (c *serverNameCheckCreds) Info() credentials.ProtocolInfo {
func (c *serverNameCheckCreds) Clone() credentials.TransportCredentials { func (c *serverNameCheckCreds) Clone() credentials.TransportCredentials {
return &serverNameCheckCreds{} return &serverNameCheckCreds{}
} }
func (c *serverNameCheckCreds) OverrideServerName(s string) error { func (c *serverNameCheckCreds) OverrideServerName(string) error {
return nil return nil
} }
@ -307,7 +307,7 @@ type testServer struct {
const testmdkey = "testmd" const testmdkey = "testmd"
func (s *testServer) EmptyCall(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) { func (s *testServer) EmptyCall(ctx context.Context, _ *testpb.Empty) (*testpb.Empty, error) {
md, ok := metadata.FromIncomingContext(ctx) md, ok := metadata.FromIncomingContext(ctx)
if !ok { if !ok {
return nil, status.Error(codes.Internal, "failed to receive metadata") return nil, status.Error(codes.Internal, "failed to receive metadata")
@ -319,7 +319,7 @@ func (s *testServer) EmptyCall(ctx context.Context, in *testpb.Empty) (*testpb.E
return &testpb.Empty{}, nil return &testpb.Empty{}, nil
} }
func (s *testServer) FullDuplexCall(stream testgrpc.TestService_FullDuplexCallServer) error { func (s *testServer) FullDuplexCall(testgrpc.TestService_FullDuplexCallServer) error {
return nil return nil
} }
@ -1378,7 +1378,7 @@ func (s) TestGRPCLBWithTargetNameFieldInConfig(t *testing.T) {
type failPreRPCCred struct{} type failPreRPCCred struct{}
func (failPreRPCCred) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { func (failPreRPCCred) GetRequestMetadata(_ context.Context, uri ...string) (map[string]string, error) {
if strings.Contains(uri[0], failtosendURI) { if strings.Contains(uri[0], failtosendURI) {
return nil, fmt.Errorf("rpc should fail to send") return nil, fmt.Errorf("rpc should fail to send")
} }
@ -1619,7 +1619,7 @@ func (s) TestGRPCLBStatsStreamingFailedToSend(t *testing.T) {
func (s) TestGRPCLBStatsQuashEmpty(t *testing.T) { func (s) TestGRPCLBStatsQuashEmpty(t *testing.T) {
ch := make(chan *lbpb.ClientStats) ch := make(chan *lbpb.ClientStats)
defer close(ch) defer close(ch)
if err := runAndCheckStats(t, false, ch, func(cc *grpc.ClientConn) { if err := runAndCheckStats(t, false, ch, func(*grpc.ClientConn) {
// Perform no RPCs; wait for load reports to start, which should be // Perform no RPCs; wait for load reports to start, which should be
// zero, then expect no other load report within 5x the update // zero, then expect no other load report within 5x the update
// interval. // interval.

View File

@ -52,7 +52,7 @@ func newMockClientConn() *mockClientConn {
} }
} }
func (mcc *mockClientConn) NewSubConn(addrs []resolver.Address, opts balancer.NewSubConnOptions) (balancer.SubConn, error) { func (mcc *mockClientConn) NewSubConn(addrs []resolver.Address, _ balancer.NewSubConnOptions) (balancer.SubConn, error) {
sc := &mockSubConn{mcc: mcc} sc := &mockSubConn{mcc: mcc}
mcc.mu.Lock() mcc.mu.Lock()
defer mcc.mu.Unlock() defer mcc.mu.Unlock()

View File

@ -127,7 +127,7 @@ func setupBackends(t *testing.T) []string {
// Construct and start three working backends. // Construct and start three working backends.
for i := 0; i < numBackends; i++ { for i := 0; i < numBackends; i++ {
backend := &stubserver.StubServer{ backend := &stubserver.StubServer{
EmptyCallF: func(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) { EmptyCallF: func(context.Context, *testpb.Empty) (*testpb.Empty, error) {
return &testpb.Empty{}, nil return &testpb.Empty{}, nil
}, },
FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error { FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {

View File

@ -50,7 +50,7 @@ const (
type pickfirstBuilder struct{} type pickfirstBuilder struct{}
func (pickfirstBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions) balancer.Balancer { func (pickfirstBuilder) Build(cc balancer.ClientConn, _ balancer.BuildOptions) balancer.Balancer {
b := &pickfirstBalancer{cc: cc} b := &pickfirstBalancer{cc: cc}
b.logger = internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf(logPrefix, b)) b.logger = internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf(logPrefix, b))
return b return b

View File

@ -69,11 +69,11 @@ func (s) TestConfigUpdate_ControlChannel(t *testing.T) {
// Start a couple of test backends, and set up the fake RLS servers to return // Start a couple of test backends, and set up the fake RLS servers to return
// these as a target in the RLS response. // these as a target in the RLS response.
backendCh1, backendAddress1 := startBackend(t) backendCh1, backendAddress1 := startBackend(t)
rlsServer1.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer1.SetResponseCallback(func(_ context.Context, _ *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress1}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress1}}}
}) })
backendCh2, backendAddress2 := startBackend(t) backendCh2, backendAddress2 := startBackend(t)
rlsServer2.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer2.SetResponseCallback(func(context.Context, *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress2}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress2}}}
}) })
@ -155,7 +155,7 @@ func (s) TestConfigUpdate_ControlChannelWithCreds(t *testing.T) {
// and set up the fake RLS server to return this as the target in the RLS // and set up the fake RLS server to return this as the target in the RLS
// response. // response.
backendCh, backendAddress := startBackend(t, grpc.Creds(serverCreds)) backendCh, backendAddress := startBackend(t, grpc.Creds(serverCreds))
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(_ context.Context, _ *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress}}}
}) })
@ -219,7 +219,7 @@ func (s) TestConfigUpdate_ControlChannelServiceConfig(t *testing.T) {
// Start a test backend, and set up the fake RLS server to return this as a // Start a test backend, and set up the fake RLS server to return this as a
// target in the RLS response. // target in the RLS response.
backendCh, backendAddress := startBackend(t) backendCh, backendAddress := startBackend(t)
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(_ context.Context, _ *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress}}}
}) })
@ -300,7 +300,7 @@ func (s) TestConfigUpdate_ChildPolicyConfigs(t *testing.T) {
testBackendCh, testBackendAddress := startBackend(t) testBackendCh, testBackendAddress := startBackend(t)
// Set up the RLS server to respond with the test backend. // Set up the RLS server to respond with the test backend.
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(_ context.Context, _ *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}}
}) })
@ -521,7 +521,7 @@ func (s) TestConfigUpdate_BadChildPolicyConfigs(t *testing.T) {
// Set up the RLS server to respond with a bad target field which is expected // Set up the RLS server to respond with a bad target field which is expected
// to cause the child policy's ParseTarget to fail and should result in the LB // to cause the child policy's ParseTarget to fail and should result in the LB
// policy creating a lame child policy wrapper. // policy creating a lame child policy wrapper.
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(_ context.Context, _ *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{e2e.RLSChildPolicyBadTarget}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{e2e.RLSChildPolicyBadTarget}}}
}) })
@ -590,7 +590,7 @@ func (s) TestConfigUpdate_DataCacheSizeDecrease(t *testing.T) {
// these as targets in the RLS response, based on request keys. // these as targets in the RLS response, based on request keys.
backendCh1, backendAddress1 := startBackend(t) backendCh1, backendAddress1 := startBackend(t)
backendCh2, backendAddress2 := startBackend(t) backendCh2, backendAddress2 := startBackend(t)
rlsServer.SetResponseCallback(func(ctx context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
if req.KeyMap["k1"] == "v1" { if req.KeyMap["k1"] == "v1" {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress1}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress1}}}
} }
@ -717,7 +717,7 @@ func (s) TestPickerUpdateOnDataCacheSizeDecrease(t *testing.T) {
// these as targets in the RLS response, based on request keys. // these as targets in the RLS response, based on request keys.
backendCh1, backendAddress1 := startBackend(t) backendCh1, backendAddress1 := startBackend(t)
backendCh2, backendAddress2 := startBackend(t) backendCh2, backendAddress2 := startBackend(t)
rlsServer.SetResponseCallback(func(ctx context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
if req.KeyMap["k1"] == "v1" { if req.KeyMap["k1"] == "v1" {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress1}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress1}}}
} }
@ -859,7 +859,7 @@ func (s) TestDataCachePurging(t *testing.T) {
// Start a test backend, and set up the fake RLS server to return this as a // Start a test backend, and set up the fake RLS server to return this as a
// target in the RLS response. // target in the RLS response.
backendCh, backendAddress := startBackend(t) backendCh, backendAddress := startBackend(t)
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(_ context.Context, _ *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress}}}
}) })
@ -950,7 +950,7 @@ func (s) TestControlChannelConnectivityStateMonitoring(t *testing.T) {
// Start a test backend, and set up the fake RLS server to return this as a // Start a test backend, and set up the fake RLS server to return this as a
// target in the RLS response. // target in the RLS response.
backendCh, backendAddress := startBackend(t) backendCh, backendAddress := startBackend(t)
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(_ context.Context, _ *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{backendAddress}}}
}) })
@ -1121,7 +1121,7 @@ func (s) TestUpdateStatePauses(t *testing.T) {
// Start a test backend and set the RLS server to respond with it. // Start a test backend and set the RLS server to respond with it.
testBackendCh, testBackendAddress := startBackend(t) testBackendCh, testBackendAddress := startBackend(t)
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(_ context.Context, _ *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}}
}) })

View File

@ -74,7 +74,7 @@ func (s) TestLookupFailure(t *testing.T) {
overrideAdaptiveThrottler(t, neverThrottlingThrottler()) overrideAdaptiveThrottler(t, neverThrottlingThrottler())
// Setup the RLS server to respond with errors. // Setup the RLS server to respond with errors.
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(context.Context, *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Err: errors.New("rls failure")} return &rlstest.RouteLookupResponse{Err: errors.New("rls failure")}
}) })
@ -109,7 +109,7 @@ func (s) TestLookupFailure(t *testing.T) {
// respond within the configured rpc timeout. // respond within the configured rpc timeout.
func (s) TestLookupDeadlineExceeded(t *testing.T) { func (s) TestLookupDeadlineExceeded(t *testing.T) {
// A unary interceptor which returns a status error with DeadlineExceeded. // A unary interceptor which returns a status error with DeadlineExceeded.
interceptor := func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { interceptor := func(context.Context, any, *grpc.UnaryServerInfo, grpc.UnaryHandler) (resp any, err error) {
return nil, status.Error(codes.DeadlineExceeded, "deadline exceeded") return nil, status.Error(codes.DeadlineExceeded, "deadline exceeded")
} }
@ -260,7 +260,7 @@ func testControlChannelCredsSuccess(t *testing.T, sopts []grpc.ServerOption, bop
overrideAdaptiveThrottler(t, neverThrottlingThrottler()) overrideAdaptiveThrottler(t, neverThrottlingThrottler())
// Setup the RLS server to respond with a valid response. // Setup the RLS server to respond with a valid response.
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(context.Context, *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return lookupResponse return lookupResponse
}) })

View File

@ -61,7 +61,7 @@ type fakeBackoffStrategy struct {
backoff time.Duration backoff time.Duration
} }
func (f *fakeBackoffStrategy) Backoff(retries int) time.Duration { func (f *fakeBackoffStrategy) Backoff(int) time.Duration {
return f.backoff return f.backoff
} }
@ -171,7 +171,7 @@ func startBackend(t *testing.T, sopts ...grpc.ServerOption) (rpcCh chan struct{}
rpcCh = make(chan struct{}, 1) rpcCh = make(chan struct{}, 1)
backend := &stubserver.StubServer{ backend := &stubserver.StubServer{
EmptyCallF: func(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) { EmptyCallF: func(context.Context, *testpb.Empty) (*testpb.Empty, error) {
select { select {
case rpcCh <- struct{}{}: case rpcCh <- struct{}{}:
default: default:

View File

@ -48,7 +48,7 @@ import (
func (s) TestNoNonEmptyTargetsReturnsError(t *testing.T) { func (s) TestNoNonEmptyTargetsReturnsError(t *testing.T) {
// Setup RLS Server to return a response with an empty target string. // Setup RLS Server to return a response with an empty target string.
rlsServer, rlsReqCh := rlstest.SetupFakeRLSServer(t, nil) rlsServer, rlsReqCh := rlstest.SetupFakeRLSServer(t, nil)
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(context.Context, *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{}}
}) })
@ -193,7 +193,7 @@ func (s) TestPick_DataCacheMiss_PendingEntryExists(t *testing.T) {
// also lead to creation of a pending entry, and further RPCs by the // also lead to creation of a pending entry, and further RPCs by the
// client should not result in RLS requests being sent out. // client should not result in RLS requests being sent out.
rlsReqCh := make(chan struct{}, 1) rlsReqCh := make(chan struct{}, 1)
interceptor := func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { interceptor := func(ctx context.Context, _ any, _ *grpc.UnaryServerInfo, _ grpc.UnaryHandler) (resp any, err error) {
rlsReqCh <- struct{}{} rlsReqCh <- struct{}{}
<-ctx.Done() <-ctx.Done()
return nil, ctx.Err() return nil, ctx.Err()
@ -260,7 +260,7 @@ func (s) TestPick_DataCacheHit_NoPendingEntry_ValidEntry(t *testing.T) {
// Start a test backend, and setup the fake RLS server to return this as a // Start a test backend, and setup the fake RLS server to return this as a
// target in the RLS response. // target in the RLS response.
testBackendCh, testBackendAddress := startBackend(t) testBackendCh, testBackendAddress := startBackend(t)
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(context.Context, *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}}
}) })
@ -304,7 +304,7 @@ func (s) TestPick_DataCacheHit_NoPendingEntry_ValidEntry_WithHeaderData(t *testi
// RLS server to be part of RPC metadata as X-Google-RLS-Data header. // RLS server to be part of RPC metadata as X-Google-RLS-Data header.
const headerDataContents = "foo,bar,baz" const headerDataContents = "foo,bar,baz"
backend := &stubserver.StubServer{ backend := &stubserver.StubServer{
EmptyCallF: func(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) { EmptyCallF: func(ctx context.Context, _ *testpb.Empty) (*testpb.Empty, error) {
gotHeaderData := metadata.ValueFromIncomingContext(ctx, "x-google-rls-data") gotHeaderData := metadata.ValueFromIncomingContext(ctx, "x-google-rls-data")
if len(gotHeaderData) != 1 || gotHeaderData[0] != headerDataContents { if len(gotHeaderData) != 1 || gotHeaderData[0] != headerDataContents {
return nil, fmt.Errorf("got metadata in `X-Google-RLS-Data` is %v, want %s", gotHeaderData, headerDataContents) return nil, fmt.Errorf("got metadata in `X-Google-RLS-Data` is %v, want %s", gotHeaderData, headerDataContents)
@ -320,7 +320,7 @@ func (s) TestPick_DataCacheHit_NoPendingEntry_ValidEntry_WithHeaderData(t *testi
// Setup the fake RLS server to return the above backend as a target in the // Setup the fake RLS server to return the above backend as a target in the
// RLS response. Also, populate the header data field in the response. // RLS response. Also, populate the header data field in the response.
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(context.Context, *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{ return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{
Targets: []string{backend.Address}, Targets: []string{backend.Address},
HeaderData: headerDataContents, HeaderData: headerDataContents,
@ -389,7 +389,7 @@ func (s) TestPick_DataCacheHit_NoPendingEntry_StaleEntry(t *testing.T) {
// Start a test backend, and setup the fake RLS server to return // Start a test backend, and setup the fake RLS server to return
// this as a target in the RLS response. // this as a target in the RLS response.
testBackendCh, testBackendAddress := startBackend(t) testBackendCh, testBackendAddress := startBackend(t)
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(context.Context, *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}}
}) })
@ -498,7 +498,7 @@ func (s) TestPick_DataCacheHit_NoPendingEntry_ExpiredEntry(t *testing.T) {
// Start a test backend, and setup the fake RLS server to return // Start a test backend, and setup the fake RLS server to return
// this as a target in the RLS response. // this as a target in the RLS response.
testBackendCh, testBackendAddress := startBackend(t) testBackendCh, testBackendAddress := startBackend(t)
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(context.Context, *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}}
}) })
@ -597,7 +597,7 @@ func (s) TestPick_DataCacheHit_NoPendingEntry_ExpiredEntryInBackoff(t *testing.T
// Start a test backend, and set up the fake RLS server to return this as // Start a test backend, and set up the fake RLS server to return this as
// a target in the RLS response. // a target in the RLS response.
testBackendCh, testBackendAddress := startBackend(t) testBackendCh, testBackendAddress := startBackend(t)
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(context.Context, *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}}
}) })
@ -622,7 +622,7 @@ func (s) TestPick_DataCacheHit_NoPendingEntry_ExpiredEntryInBackoff(t *testing.T
// Set up the fake RLS server to return errors. This will push the cache // Set up the fake RLS server to return errors. This will push the cache
// entry into backoff. // entry into backoff.
var rlsLastErr = status.Error(codes.DeadlineExceeded, "last RLS request failed") var rlsLastErr = status.Error(codes.DeadlineExceeded, "last RLS request failed")
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(context.Context, *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Err: rlsLastErr} return &rlstest.RouteLookupResponse{Err: rlsLastErr}
}) })
@ -698,7 +698,7 @@ func (s) TestPick_DataCacheHit_PendingEntryExists_StaleEntry(t *testing.T) {
// Start a test backend, and setup the fake RLS server to return // Start a test backend, and setup the fake RLS server to return
// this as a target in the RLS response. // this as a target in the RLS response.
testBackendCh, testBackendAddress := startBackend(t) testBackendCh, testBackendAddress := startBackend(t)
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(context.Context, *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}}
}) })
@ -796,7 +796,7 @@ func (s) TestPick_DataCacheHit_PendingEntryExists_ExpiredEntry(t *testing.T) {
// Start a test backend, and setup the fake RLS server to return // Start a test backend, and setup the fake RLS server to return
// this as a target in the RLS response. // this as a target in the RLS response.
testBackendCh, testBackendAddress := startBackend(t) testBackendCh, testBackendAddress := startBackend(t)
rlsServer.SetResponseCallback(func(_ context.Context, req *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse { rlsServer.SetResponseCallback(func(context.Context, *rlspb.RouteLookupRequest) *rlstest.RouteLookupResponse {
return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}} return &rlstest.RouteLookupResponse{Resp: &rlspb.RouteLookupResponse{Targets: []string{testBackendAddress}}}
}) })

View File

@ -440,7 +440,7 @@ func (p *picker) start(ctx context.Context) {
}() }()
} }
func (p *picker) Pick(info balancer.PickInfo) (balancer.PickResult, error) { func (p *picker) Pick(balancer.PickInfo) (balancer.PickResult, error) {
// Read the scheduler atomically. All scheduler operations are threadsafe, // Read the scheduler atomically. All scheduler operations are threadsafe,
// and if the scheduler is replaced during this usage, we want to use the // and if the scheduler is replaced during this usage, we want to use the
// scheduler that was live when the pick started. // scheduler that was live when the pick started.

View File

@ -1327,7 +1327,7 @@ func (s) TestUpdateStatePauses(t *testing.T) {
cc := &tcc{BalancerClientConn: testutils.NewBalancerClientConn(t)} cc := &tcc{BalancerClientConn: testutils.NewBalancerClientConn(t)}
balFuncs := stub.BalancerFuncs{ balFuncs := stub.BalancerFuncs{
UpdateClientConnState: func(bd *stub.BalancerData, s balancer.ClientConnState) error { UpdateClientConnState: func(bd *stub.BalancerData, _ balancer.ClientConnState) error {
bd.ClientConn.UpdateState(balancer.State{ConnectivityState: connectivity.TransientFailure, Picker: nil}) bd.ClientConn.UpdateState(balancer.State{ConnectivityState: connectivity.TransientFailure, Picker: nil})
bd.ClientConn.UpdateState(balancer.State{ConnectivityState: connectivity.Ready, Picker: nil}) bd.ClientConn.UpdateState(balancer.State{ConnectivityState: connectivity.Ready, Picker: nil})
return nil return nil

View File

@ -192,7 +192,7 @@ func (ccb *ccBalancerWrapper) NewSubConn(addrs []resolver.Address, opts balancer
return acbw, nil return acbw, nil
} }
func (ccb *ccBalancerWrapper) RemoveSubConn(sc balancer.SubConn) { func (ccb *ccBalancerWrapper) RemoveSubConn(balancer.SubConn) {
// The graceful switch balancer will never call this. // The graceful switch balancer will never call this.
logger.Errorf("ccb RemoveSubConn(%v) called unexpectedly, sc") logger.Errorf("ccb RemoveSubConn(%v) called unexpectedly, sc")
} }

View File

@ -384,7 +384,7 @@ func makeClients(bf stats.Features) ([]testgrpc.BenchmarkServiceClient, func())
if bf.UseBufConn { if bf.UseBufConn {
bcLis := bufconn.Listen(256 * 1024) bcLis := bufconn.Listen(256 * 1024)
lis = bcLis lis = bcLis
opts = append(opts, grpc.WithContextDialer(func(ctx context.Context, address string) (net.Conn, error) { opts = append(opts, grpc.WithContextDialer(func(ctx context.Context, _ string) (net.Conn, error) {
return nw.ContextDialer(func(context.Context, string, string) (net.Conn, error) { return nw.ContextDialer(func(context.Context, string, string) (net.Conn, error) {
return bcLis.Dial() return bcLis.Dial()
})(ctx, "", "") })(ctx, "", "")
@ -395,7 +395,7 @@ func makeClients(bf stats.Features) ([]testgrpc.BenchmarkServiceClient, func())
if err != nil { if err != nil {
logger.Fatalf("Failed to listen: %v", err) logger.Fatalf("Failed to listen: %v", err)
} }
opts = append(opts, grpc.WithContextDialer(func(ctx context.Context, address string) (net.Conn, error) { opts = append(opts, grpc.WithContextDialer(func(ctx context.Context, _ string) (net.Conn, error) {
return nw.ContextDialer((internal.NetDialerWithTCPKeepalive().DialContext))(ctx, "tcp", lis.Addr().String()) return nw.ContextDialer((internal.NetDialerWithTCPKeepalive().DialContext))(ctx, "tcp", lis.Addr().String())
})) }))
} }
@ -418,7 +418,7 @@ func makeClients(bf stats.Features) ([]testgrpc.BenchmarkServiceClient, func())
func makeFuncUnary(bf stats.Features) (rpcCallFunc, rpcCleanupFunc) { func makeFuncUnary(bf stats.Features) (rpcCallFunc, rpcCleanupFunc) {
clients, cleanup := makeClients(bf) clients, cleanup := makeClients(bf)
return func(cn, pos int) { return func(cn, _ int) {
reqSizeBytes := bf.ReqSizeBytes reqSizeBytes := bf.ReqSizeBytes
respSizeBytes := bf.RespSizeBytes respSizeBytes := bf.RespSizeBytes
if bf.ReqPayloadCurve != nil { if bf.ReqPayloadCurve != nil {

View File

@ -69,7 +69,7 @@ type testServer struct {
testgrpc.UnimplementedBenchmarkServiceServer testgrpc.UnimplementedBenchmarkServiceServer
} }
func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { func (s *testServer) UnaryCall(_ context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{ return &testpb.SimpleResponse{
Payload: NewPayload(in.ResponseType, int(in.ResponseSize)), Payload: NewPayload(in.ResponseType, int(in.ResponseSize)),
}, nil }, nil
@ -218,7 +218,7 @@ type byteBufServer struct {
// UnaryCall is an empty function and is not used for benchmark. // UnaryCall is an empty function and is not used for benchmark.
// If bytebuf UnaryCall benchmark is needed later, the function body needs to be updated. // If bytebuf UnaryCall benchmark is needed later, the function body needs to be updated.
func (s *byteBufServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { func (s *byteBufServer) UnaryCall(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{}, nil return &testpb.SimpleResponse{}, nil
} }
@ -318,7 +318,7 @@ func DoStreamingRoundTripPreloaded(stream testgrpc.BenchmarkService_StreamingCal
} }
// DoByteBufStreamingRoundTrip performs a round trip for a single streaming rpc, using a custom codec for byte buffer. // DoByteBufStreamingRoundTrip performs a round trip for a single streaming rpc, using a custom codec for byte buffer.
func DoByteBufStreamingRoundTrip(stream testgrpc.BenchmarkService_StreamingCallClient, reqSize, respSize int) error { func DoByteBufStreamingRoundTrip(stream testgrpc.BenchmarkService_StreamingCallClient, reqSize, _ int) error {
out := make([]byte, reqSize) out := make([]byte, reqSize)
if err := stream.(grpc.ClientStream).SendMsg(&out); err != nil { if err := stream.(grpc.ClientStream).SendMsg(&out); err != nil {
return fmt.Errorf("/BenchmarkService/StreamingCall.(ClientStream).SendMsg(_) = %v, want <nil>", err) return fmt.Errorf("/BenchmarkService/StreamingCall.(ClientStream).SendMsg(_) = %v, want <nil>", err)

View File

@ -46,9 +46,9 @@ type bufConn struct {
func (bufConn) Close() error { panic("unimplemented") } func (bufConn) Close() error { panic("unimplemented") }
func (bufConn) LocalAddr() net.Addr { panic("unimplemented") } func (bufConn) LocalAddr() net.Addr { panic("unimplemented") }
func (bufConn) RemoteAddr() net.Addr { panic("unimplemented") } func (bufConn) RemoteAddr() net.Addr { panic("unimplemented") }
func (bufConn) SetDeadline(t time.Time) error { panic("unimplemented") } func (bufConn) SetDeadline(time.Time) error { panic("unimplemented") }
func (bufConn) SetReadDeadline(t time.Time) error { panic("unimplemented") } func (bufConn) SetReadDeadline(time.Time) error { panic("unimplemented") }
func (bufConn) SetWriteDeadline(t time.Time) error { panic("unimplemented") } func (bufConn) SetWriteDeadline(time.Time) error { panic("unimplemented") }
func restoreHooks() func() { func restoreHooks() func() {
s := sleep s := sleep

View File

@ -188,12 +188,12 @@ func (s *workerServer) RunClient(stream testgrpc.WorkerService_RunClientServer)
} }
} }
func (s *workerServer) CoreCount(ctx context.Context, in *testpb.CoreRequest) (*testpb.CoreResponse, error) { func (s *workerServer) CoreCount(context.Context, *testpb.CoreRequest) (*testpb.CoreResponse, error) {
logger.Infof("core count: %v", runtime.NumCPU()) logger.Infof("core count: %v", runtime.NumCPU())
return &testpb.CoreResponse{Cores: int32(runtime.NumCPU())}, nil return &testpb.CoreResponse{Cores: int32(runtime.NumCPU())}, nil
} }
func (s *workerServer) QuitWorker(ctx context.Context, in *testpb.Void) (*testpb.Void, error) { func (s *workerServer) QuitWorker(context.Context, *testpb.Void) (*testpb.Void, error) {
logger.Infof("quitting worker") logger.Infof("quitting worker")
s.stop <- true s.stop <- true
return &testpb.Void{}, nil return &testpb.Void{}, nil

View File

@ -51,7 +51,7 @@ type serverImpl struct {
channelzgrpc.UnimplementedChannelzServer channelzgrpc.UnimplementedChannelzServer
} }
func (s *serverImpl) GetChannel(ctx context.Context, req *channelzpb.GetChannelRequest) (*channelzpb.GetChannelResponse, error) { func (s *serverImpl) GetChannel(_ context.Context, req *channelzpb.GetChannelRequest) (*channelzpb.GetChannelResponse, error) {
ch, err := protoconv.GetChannel(req.GetChannelId()) ch, err := protoconv.GetChannel(req.GetChannelId())
if err != nil { if err != nil {
return nil, err return nil, err
@ -59,13 +59,13 @@ func (s *serverImpl) GetChannel(ctx context.Context, req *channelzpb.GetChannelR
return &channelzpb.GetChannelResponse{Channel: ch}, nil return &channelzpb.GetChannelResponse{Channel: ch}, nil
} }
func (s *serverImpl) GetTopChannels(ctx context.Context, req *channelzpb.GetTopChannelsRequest) (*channelzpb.GetTopChannelsResponse, error) { func (s *serverImpl) GetTopChannels(_ context.Context, req *channelzpb.GetTopChannelsRequest) (*channelzpb.GetTopChannelsResponse, error) {
resp := &channelzpb.GetTopChannelsResponse{} resp := &channelzpb.GetTopChannelsResponse{}
resp.Channel, resp.End = protoconv.GetTopChannels(req.GetStartChannelId(), int(req.GetMaxResults())) resp.Channel, resp.End = protoconv.GetTopChannels(req.GetStartChannelId(), int(req.GetMaxResults()))
return resp, nil return resp, nil
} }
func (s *serverImpl) GetServer(ctx context.Context, req *channelzpb.GetServerRequest) (*channelzpb.GetServerResponse, error) { func (s *serverImpl) GetServer(_ context.Context, req *channelzpb.GetServerRequest) (*channelzpb.GetServerResponse, error) {
srv, err := protoconv.GetServer(req.GetServerId()) srv, err := protoconv.GetServer(req.GetServerId())
if err != nil { if err != nil {
return nil, err return nil, err
@ -73,13 +73,13 @@ func (s *serverImpl) GetServer(ctx context.Context, req *channelzpb.GetServerReq
return &channelzpb.GetServerResponse{Server: srv}, nil return &channelzpb.GetServerResponse{Server: srv}, nil
} }
func (s *serverImpl) GetServers(ctx context.Context, req *channelzpb.GetServersRequest) (*channelzpb.GetServersResponse, error) { func (s *serverImpl) GetServers(_ context.Context, req *channelzpb.GetServersRequest) (*channelzpb.GetServersResponse, error) {
resp := &channelzpb.GetServersResponse{} resp := &channelzpb.GetServersResponse{}
resp.Server, resp.End = protoconv.GetServers(req.GetStartServerId(), int(req.GetMaxResults())) resp.Server, resp.End = protoconv.GetServers(req.GetStartServerId(), int(req.GetMaxResults()))
return resp, nil return resp, nil
} }
func (s *serverImpl) GetSubchannel(ctx context.Context, req *channelzpb.GetSubchannelRequest) (*channelzpb.GetSubchannelResponse, error) { func (s *serverImpl) GetSubchannel(_ context.Context, req *channelzpb.GetSubchannelRequest) (*channelzpb.GetSubchannelResponse, error) {
subChan, err := protoconv.GetSubChannel(req.GetSubchannelId()) subChan, err := protoconv.GetSubChannel(req.GetSubchannelId())
if err != nil { if err != nil {
return nil, err return nil, err
@ -87,13 +87,13 @@ func (s *serverImpl) GetSubchannel(ctx context.Context, req *channelzpb.GetSubch
return &channelzpb.GetSubchannelResponse{Subchannel: subChan}, nil return &channelzpb.GetSubchannelResponse{Subchannel: subChan}, nil
} }
func (s *serverImpl) GetServerSockets(ctx context.Context, req *channelzpb.GetServerSocketsRequest) (*channelzpb.GetServerSocketsResponse, error) { func (s *serverImpl) GetServerSockets(_ context.Context, req *channelzpb.GetServerSocketsRequest) (*channelzpb.GetServerSocketsResponse, error) {
resp := &channelzpb.GetServerSocketsResponse{} resp := &channelzpb.GetServerSocketsResponse{}
resp.SocketRef, resp.End = protoconv.GetServerSockets(req.GetServerId(), req.GetStartSocketId(), int(req.GetMaxResults())) resp.SocketRef, resp.End = protoconv.GetServerSockets(req.GetServerId(), req.GetStartSocketId(), int(req.GetMaxResults()))
return resp, nil return resp, nil
} }
func (s *serverImpl) GetSocket(ctx context.Context, req *channelzpb.GetSocketRequest) (*channelzpb.GetSocketResponse, error) { func (s *serverImpl) GetSocket(_ context.Context, req *channelzpb.GetSocketRequest) (*channelzpb.GetSocketResponse, error) {
socket, err := protoconv.GetSocket(req.GetSocketId()) socket, err := protoconv.GetSocket(req.GetSocketId())
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -268,7 +268,7 @@ func (s) TestParsedTarget_WithCustomDialer(t *testing.T) {
for _, test := range tests { for _, test := range tests {
t.Run(test.target, func(t *testing.T) { t.Run(test.target, func(t *testing.T) {
addrCh := make(chan string, 1) addrCh := make(chan string, 1)
dialer := func(ctx context.Context, address string) (net.Conn, error) { dialer := func(_ context.Context, address string) (net.Conn, error) {
addrCh <- address addrCh <- address
return nil, errors.New("dialer error") return nil, errors.New("dialer error")
} }

View File

@ -73,11 +73,11 @@ func (serviceGenerateHelper) generateClientStruct(g *protogen.GeneratedFile, cli
g.P() g.P()
} }
func (serviceGenerateHelper) generateNewClientDefinitions(g *protogen.GeneratedFile, service *protogen.Service, clientName string) { func (serviceGenerateHelper) generateNewClientDefinitions(g *protogen.GeneratedFile, _ *protogen.Service, clientName string) {
g.P("return &", unexport(clientName), "{cc}") g.P("return &", unexport(clientName), "{cc}")
} }
func (serviceGenerateHelper) generateUnimplementedServerType(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service) { func (serviceGenerateHelper) generateUnimplementedServerType(_ *protogen.Plugin, _ *protogen.File, g *protogen.GeneratedFile, service *protogen.Service) {
serverType := service.GoName + "Server" serverType := service.GoName + "Server"
mustOrShould := "must" mustOrShould := "must"
if !*requireUnimplemented { if !*requireUnimplemented {
@ -119,7 +119,7 @@ func (serviceGenerateHelper) generateServerFunctions(gen *protogen.Plugin, file
genServiceDesc(file, g, serviceDescVar, serverType, service, handlerNames) genServiceDesc(file, g, serviceDescVar, serverType, service, handlerNames)
} }
func (serviceGenerateHelper) formatHandlerFuncName(service *protogen.Service, hname string) string { func (serviceGenerateHelper) formatHandlerFuncName(_ *protogen.Service, hname string) string {
return hname return hname
} }
@ -354,7 +354,7 @@ func clientStreamInterface(g *protogen.GeneratedFile, method *protogen.Method) s
return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingClient")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]" return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingClient")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"
} }
func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method, index int) { func genClientMethod(_ *protogen.Plugin, _ *protogen.File, g *protogen.GeneratedFile, method *protogen.Method, index int) {
service := method.Parent service := method.Parent
fmSymbol := helper.formatFullMethodSymbol(service, method) fmSymbol := helper.formatFullMethodSymbol(service, method)
@ -522,7 +522,7 @@ func serverStreamInterface(g *protogen.GeneratedFile, method *protogen.Method) s
return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingServer")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]" return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingServer")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"
} }
func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method, hnameFuncNameFormatter func(string) string) string { func genServerMethod(_ *protogen.Plugin, _ *protogen.File, g *protogen.GeneratedFile, method *protogen.Method, hnameFuncNameFormatter func(string) string) string {
service := method.Parent service := method.Parent
hname := fmt.Sprintf("_%s_%s_Handler", service.GoName, method.GoName) hname := fmt.Sprintf("_%s_%s_Handler", service.GoName, method.GoName)

View File

@ -128,7 +128,7 @@ type altsHandshaker struct {
// NewClientHandshaker creates a core.Handshaker that performs a client-side // NewClientHandshaker creates a core.Handshaker that performs a client-side
// ALTS handshake by acting as a proxy between the peer and the ALTS handshaker // ALTS handshake by acting as a proxy between the peer and the ALTS handshaker
// service in the metadata server. // service in the metadata server.
func NewClientHandshaker(ctx context.Context, conn *grpc.ClientConn, c net.Conn, opts *ClientHandshakerOptions) (core.Handshaker, error) { func NewClientHandshaker(_ context.Context, conn *grpc.ClientConn, c net.Conn, opts *ClientHandshakerOptions) (core.Handshaker, error) {
return &altsHandshaker{ return &altsHandshaker{
stream: nil, stream: nil,
conn: c, conn: c,
@ -141,7 +141,7 @@ func NewClientHandshaker(ctx context.Context, conn *grpc.ClientConn, c net.Conn,
// NewServerHandshaker creates a core.Handshaker that performs a server-side // NewServerHandshaker creates a core.Handshaker that performs a server-side
// ALTS handshake by acting as a proxy between the peer and the ALTS handshaker // ALTS handshake by acting as a proxy between the peer and the ALTS handshaker
// service in the metadata server. // service in the metadata server.
func NewServerHandshaker(ctx context.Context, conn *grpc.ClientConn, c net.Conn, opts *ServerHandshakerOptions) (core.Handshaker, error) { func NewServerHandshaker(_ context.Context, conn *grpc.ClientConn, c net.Conn, opts *ServerHandshakerOptions) (core.Handshaker, error) {
return &altsHandshaker{ return &altsHandshaker{
stream: nil, stream: nil,
conn: c, conn: c,

View File

@ -273,7 +273,7 @@ func (t *testUnresponsiveRPCStream) Recv() (*altspb.HandshakerResp, error) {
return &altspb.HandshakerResp{}, nil return &altspb.HandshakerResp{}, nil
} }
func (t *testUnresponsiveRPCStream) Send(req *altspb.HandshakerReq) error { func (t *testUnresponsiveRPCStream) Send(*altspb.HandshakerReq) error {
return nil return nil
} }

View File

@ -120,12 +120,12 @@ func NewUnresponsiveTestConn() net.Conn {
} }
// Read reads from the in buffer. // Read reads from the in buffer.
func (c *unresponsiveTestConn) Read(b []byte) (n int, err error) { func (c *unresponsiveTestConn) Read([]byte) (n int, err error) {
return 0, io.EOF return 0, io.EOF
} }
// Write writes to the out buffer. // Write writes to the out buffer.
func (c *unresponsiveTestConn) Write(b []byte) (n int, err error) { func (c *unresponsiveTestConn) Write([]byte) (n int, err error) {
return 0, nil return 0, nil
} }

View File

@ -43,11 +43,11 @@ type testCreds struct {
typ string typ string
} }
func (c *testCreds) ClientHandshake(ctx context.Context, authority string, rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { func (c *testCreds) ClientHandshake(context.Context, string, net.Conn) (net.Conn, credentials.AuthInfo, error) {
return nil, &testAuthInfo{typ: c.typ}, nil return nil, &testAuthInfo{typ: c.typ}, nil
} }
func (c *testCreds) ServerHandshake(conn net.Conn) (net.Conn, credentials.AuthInfo, error) { func (c *testCreds) ServerHandshake(net.Conn) (net.Conn, credentials.AuthInfo, error) {
return nil, &testAuthInfo{typ: c.typ}, nil return nil, &testAuthInfo{typ: c.typ}, nil
} }

View File

@ -40,7 +40,7 @@ func NewCredentials() credentials.TransportCredentials {
// NoSecurity. // NoSecurity.
type insecureTC struct{} type insecureTC struct{}
func (insecureTC) ClientHandshake(ctx context.Context, _ string, conn net.Conn) (net.Conn, credentials.AuthInfo, error) { func (insecureTC) ClientHandshake(_ context.Context, _ string, conn net.Conn) (net.Conn, credentials.AuthInfo, error) {
return conn, info{credentials.CommonAuthInfo{SecurityLevel: credentials.NoSecurity}}, nil return conn, info{credentials.CommonAuthInfo{SecurityLevel: credentials.NoSecurity}}, nil
} }

View File

@ -77,7 +77,7 @@ func getSecurityLevel(network, addr string) (credentials.SecurityLevel, error) {
} }
} }
func (*localTC) ClientHandshake(ctx context.Context, authority string, conn net.Conn) (net.Conn, credentials.AuthInfo, error) { func (*localTC) ClientHandshake(_ context.Context, _ string, conn net.Conn) (net.Conn, credentials.AuthInfo, error) {
secLevel, err := getSecurityLevel(conn.RemoteAddr().Network(), conn.RemoteAddr().String()) secLevel, err := getSecurityLevel(conn.RemoteAddr().Network(), conn.RemoteAddr().String())
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err

View File

@ -38,7 +38,7 @@ type TokenSource struct {
} }
// GetRequestMetadata gets the request metadata as a map from a TokenSource. // GetRequestMetadata gets the request metadata as a map from a TokenSource.
func (ts TokenSource) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { func (ts TokenSource) GetRequestMetadata(ctx context.Context, _ ...string) (map[string]string, error) {
token, err := ts.Token() token, err := ts.Token()
if err != nil { if err != nil {
return nil, err return nil, err
@ -127,7 +127,7 @@ func NewOauthAccess(token *oauth2.Token) credentials.PerRPCCredentials {
return oauthAccess{token: *token} return oauthAccess{token: *token}
} }
func (oa oauthAccess) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { func (oa oauthAccess) GetRequestMetadata(ctx context.Context, _ ...string) (map[string]string, error) {
ri, _ := credentials.RequestInfoFromContext(ctx) ri, _ := credentials.RequestInfoFromContext(ctx)
if err := credentials.CheckSecurityLevel(ri.AuthInfo, credentials.PrivacyAndIntegrity); err != nil { if err := credentials.CheckSecurityLevel(ri.AuthInfo, credentials.PrivacyAndIntegrity); err != nil {
return nil, fmt.Errorf("unable to transfer oauthAccess PerRPCCredentials: %v", err) return nil, fmt.Errorf("unable to transfer oauthAccess PerRPCCredentials: %v", err)
@ -156,7 +156,7 @@ type serviceAccount struct {
t *oauth2.Token t *oauth2.Token
} }
func (s *serviceAccount) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { func (s *serviceAccount) GetRequestMetadata(ctx context.Context, _ ...string) (map[string]string, error) {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
if !s.t.Valid() { if !s.t.Valid() {

View File

@ -109,7 +109,7 @@ func createTestContext(ctx context.Context, s credentials.SecurityLevel) context
// Read method. // Read method.
type errReader struct{} type errReader struct{}
func (r errReader) Read(b []byte) (n int, err error) { func (r errReader) Read([]byte) (n int, err error) {
return 0, errors.New("read error") return 0, errors.New("read error")
} }
@ -155,7 +155,7 @@ func overrideHTTPClient(fc *testutils.FakeHTTPClient) func() {
// our tests. // our tests.
func overrideSubjectTokenGood() func() { func overrideSubjectTokenGood() func() {
origReadSubjectTokenFrom := readSubjectTokenFrom origReadSubjectTokenFrom := readSubjectTokenFrom
readSubjectTokenFrom = func(path string) ([]byte, error) { readSubjectTokenFrom = func(string) ([]byte, error) {
return []byte(subjectTokenContents), nil return []byte(subjectTokenContents), nil
} }
return func() { readSubjectTokenFrom = origReadSubjectTokenFrom } return func() { readSubjectTokenFrom = origReadSubjectTokenFrom }
@ -164,7 +164,7 @@ func overrideSubjectTokenGood() func() {
// Overrides the subject token read to always return an error. // Overrides the subject token read to always return an error.
func overrideSubjectTokenError() func() { func overrideSubjectTokenError() func() {
origReadSubjectTokenFrom := readSubjectTokenFrom origReadSubjectTokenFrom := readSubjectTokenFrom
readSubjectTokenFrom = func(path string) ([]byte, error) { readSubjectTokenFrom = func(string) ([]byte, error) {
return nil, errors.New("error reading subject token") return nil, errors.New("error reading subject token")
} }
return func() { readSubjectTokenFrom = origReadSubjectTokenFrom } return func() { readSubjectTokenFrom = origReadSubjectTokenFrom }
@ -174,7 +174,7 @@ func overrideSubjectTokenError() func() {
// our tests. // our tests.
func overrideActorTokenGood() func() { func overrideActorTokenGood() func() {
origReadActorTokenFrom := readActorTokenFrom origReadActorTokenFrom := readActorTokenFrom
readActorTokenFrom = func(path string) ([]byte, error) { readActorTokenFrom = func(string) ([]byte, error) {
return []byte(actorTokenContents), nil return []byte(actorTokenContents), nil
} }
return func() { readActorTokenFrom = origReadActorTokenFrom } return func() { readActorTokenFrom = origReadActorTokenFrom }
@ -183,7 +183,7 @@ func overrideActorTokenGood() func() {
// Overrides the actor token read to always return an error. // Overrides the actor token read to always return an error.
func overrideActorTokenError() func() { func overrideActorTokenError() func() {
origReadActorTokenFrom := readActorTokenFrom origReadActorTokenFrom := readActorTokenFrom
readActorTokenFrom = func(path string) ([]byte, error) { readActorTokenFrom = func(string) ([]byte, error) {
return nil, errors.New("error reading actor token") return nil, errors.New("error reading actor token")
} }
return func() { readActorTokenFrom = origReadActorTokenFrom } return func() { readActorTokenFrom = origReadActorTokenFrom }

View File

@ -58,7 +58,7 @@ type wrappedProvider struct {
// closedProvider always returns errProviderClosed error. // closedProvider always returns errProviderClosed error.
type closedProvider struct{} type closedProvider struct{}
func (c closedProvider) KeyMaterial(ctx context.Context) (*KeyMaterial, error) { func (c closedProvider) KeyMaterial(context.Context) (*KeyMaterial, error) {
return nil, errProviderClosed return nil, errProviderClosed
} }

View File

@ -138,7 +138,7 @@ func (c *credsImpl) ClientHandshake(ctx context.Context, authority string, rawCo
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
cfg.VerifyPeerCertificate = func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error { cfg.VerifyPeerCertificate = func(rawCerts [][]byte, _ [][]*x509.Certificate) error {
// Parse all raw certificates presented by the peer. // Parse all raw certificates presented by the peer.
var certs []*x509.Certificate var certs []*x509.Certificate
for _, rc := range rawCerts { for _, rc := range rawCerts {

View File

@ -186,7 +186,7 @@ type fakeProvider struct {
err error err error
} }
func (f *fakeProvider) KeyMaterial(ctx context.Context) (*certprovider.KeyMaterial, error) { func (f *fakeProvider) KeyMaterial(context.Context) (*certprovider.KeyMaterial, error) {
return f.km, f.err return f.km, f.err
} }
@ -419,7 +419,7 @@ func (s) TestClientCredsHandshakeTimeout(t *testing.T) {
// server-side by simply blocking on the client-side handshake to timeout // server-side by simply blocking on the client-side handshake to timeout
// and not writing any handshake data. // and not writing any handshake data.
hErr := errors.New("server handshake error") hErr := errors.New("server handshake error")
ts := newTestServerWithHandshakeFunc(func(rawConn net.Conn) handshakeResult { ts := newTestServerWithHandshakeFunc(func(net.Conn) handshakeResult {
<-clientDone <-clientDone
return handshakeResult{err: hErr} return handshakeResult{err: hErr}
}) })

View File

@ -46,7 +46,7 @@ const goodServerWithCRLPort int = 50051
const revokedServerWithCRLPort int = 50053 const revokedServerWithCRLPort int = 50053
const insecurePort int = 50054 const insecurePort int = 50054
func (s *server) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *server) UnaryEcho(_ context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
return &pb.EchoResponse{Message: req.Message}, nil return &pb.EchoResponse{Message: req.Message}, nil
} }

View File

@ -77,7 +77,7 @@ type ecServer struct {
pb.UnimplementedEchoServer pb.UnimplementedEchoServer
} }
func (s *ecServer) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *ecServer) UnaryEcho(_ context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
return &pb.EchoResponse{Message: req.Message}, nil return &pb.EchoResponse{Message: req.Message}, nil
} }
@ -97,7 +97,7 @@ func valid(authorization []string) bool {
// the token is missing or invalid, the interceptor blocks execution of the // the token is missing or invalid, the interceptor blocks execution of the
// handler and returns an error. Otherwise, the interceptor invokes the unary // handler and returns an error. Otherwise, the interceptor invokes the unary
// handler. // handler.
func ensureValidToken(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { func ensureValidToken(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
md, ok := metadata.FromIncomingContext(ctx) md, ok := metadata.FromIncomingContext(ctx)
if !ok { if !ok {
return nil, errMissingMetadata return nil, errMissingMetadata

View File

@ -101,7 +101,7 @@ type server struct {
pb.UnimplementedEchoServer pb.UnimplementedEchoServer
} }
func (s *server) UnaryEcho(ctx context.Context, in *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *server) UnaryEcho(_ context.Context, in *pb.EchoRequest) (*pb.EchoResponse, error) {
fmt.Printf("unary echoing message %q\n", in.Message) fmt.Printf("unary echoing message %q\n", in.Message)
return &pb.EchoResponse{Message: in.Message}, nil return &pb.EchoResponse{Message: in.Message}, nil
} }
@ -144,7 +144,7 @@ func isAuthenticated(authorization []string) (username string, err error) {
// authUnaryInterceptor looks up the authorization header from the incoming RPC context, // authUnaryInterceptor looks up the authorization header from the incoming RPC context,
// retrieves the username from it and creates a new context with the username before invoking // retrieves the username from it and creates a new context with the username before invoking
// the provided handler. // the provided handler.
func authUnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { func authUnaryInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
md, ok := metadata.FromIncomingContext(ctx) md, ok := metadata.FromIncomingContext(ctx)
if !ok { if !ok {
return nil, errMissingMetadata return nil, errMissingMetadata
@ -175,7 +175,7 @@ func newWrappedStream(ctx context.Context, s grpc.ServerStream) grpc.ServerStrea
// authStreamInterceptor looks up the authorization header from the incoming RPC context, // authStreamInterceptor looks up the authorization header from the incoming RPC context,
// retrieves the username from it and creates a new context with the username before invoking // retrieves the username from it and creates a new context with the username before invoking
// the provided handler. // the provided handler.
func authStreamInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { func authStreamInterceptor(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
md, ok := metadata.FromIncomingContext(ss.Context()) md, ok := metadata.FromIncomingContext(ss.Context())
if !ok { if !ok {
return errMissingMetadata return errMissingMetadata

View File

@ -38,7 +38,7 @@ type server struct {
pb.UnimplementedEchoServer pb.UnimplementedEchoServer
} }
func (s *server) UnaryEcho(ctx context.Context, in *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *server) UnaryEcho(_ context.Context, in *pb.EchoRequest) (*pb.EchoResponse, error) {
fmt.Printf("UnaryEcho called with message %q\n", in.GetMessage()) fmt.Printf("UnaryEcho called with message %q\n", in.GetMessage())
return &pb.EchoResponse{Message: in.Message}, nil return &pb.EchoResponse{Message: in.Message}, nil
} }

View File

@ -46,7 +46,7 @@ type echoServer struct {
addr string addr string
} }
func (s *echoServer) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *echoServer) UnaryEcho(_ context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
return &pb.EchoResponse{Message: fmt.Sprintf("%s (from %s)", req.Message, s.addr)}, nil return &pb.EchoResponse{Message: fmt.Sprintf("%s (from %s)", req.Message, s.addr)}, nil
} }

View File

@ -38,7 +38,7 @@ type echoServer struct {
addr string addr string
} }
func (s *echoServer) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *echoServer) UnaryEcho(_ context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
return &pb.EchoResponse{Message: fmt.Sprintf("%s (from %s)", req.Message, s.addr)}, nil return &pb.EchoResponse{Message: fmt.Sprintf("%s (from %s)", req.Message, s.addr)}, nil
} }

View File

@ -42,7 +42,7 @@ type server struct {
} }
// SayHello implements helloworld.GreeterServer // SayHello implements helloworld.GreeterServer
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { func (s *server) SayHello(_ context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
return &pb.HelloReply{Message: "Hello " + in.Name}, nil return &pb.HelloReply{Message: "Hello " + in.Name}, nil
} }
@ -52,7 +52,7 @@ type slowServer struct {
} }
// SayHello implements helloworld.GreeterServer // SayHello implements helloworld.GreeterServer
func (s *slowServer) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { func (s *slowServer) SayHello(_ context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
// Delay 100ms ~ 200ms before replying // Delay 100ms ~ 200ms before replying
time.Sleep(time.Duration(100+rand.Intn(100)) * time.Millisecond) time.Sleep(time.Duration(100+rand.Intn(100)) * time.Millisecond)
return &pb.HelloReply{Message: "Hello " + in.Name}, nil return &pb.HelloReply{Message: "Hello " + in.Name}, nil

View File

@ -38,7 +38,7 @@ type ecServer struct {
pb.UnimplementedEchoServer pb.UnimplementedEchoServer
} }
func (s *ecServer) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *ecServer) UnaryEcho(_ context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
return &pb.EchoResponse{Message: req.Message}, nil return &pb.EchoResponse{Message: req.Message}, nil
} }

View File

@ -39,7 +39,7 @@ type ecServer struct {
pb.UnimplementedEchoServer pb.UnimplementedEchoServer
} }
func (s *ecServer) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *ecServer) UnaryEcho(_ context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
return &pb.EchoResponse{Message: req.Message}, nil return &pb.EchoResponse{Message: req.Message}, nil
} }

View File

@ -41,7 +41,7 @@ type ecServer struct {
pb.UnimplementedEchoServer pb.UnimplementedEchoServer
} }
func (s *ecServer) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *ecServer) UnaryEcho(_ context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
return &pb.EchoResponse{Message: req.Message}, nil return &pb.EchoResponse{Message: req.Message}, nil
} }

View File

@ -45,7 +45,7 @@ type server struct {
} }
// SayHello implements helloworld.GreeterServer // SayHello implements helloworld.GreeterServer
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { func (s *server) SayHello(_ context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
// Track the number of times the user has been greeted. // Track the number of times the user has been greeted.

View File

@ -41,7 +41,7 @@ type server struct {
} }
// SayHello implements helloworld.GreeterServer. // SayHello implements helloworld.GreeterServer.
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { func (s *server) SayHello(_ context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
if in.Name == "" { if in.Name == "" {
return nil, status.Errorf(codes.InvalidArgument, "request missing required field: Name") return nil, status.Errorf(codes.InvalidArgument, "request missing required field: Name")
} }

View File

@ -45,7 +45,7 @@ type echoServer struct {
pb.UnimplementedEchoServer pb.UnimplementedEchoServer
} }
func (e *echoServer) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (e *echoServer) UnaryEcho(context.Context, *pb.EchoRequest) (*pb.EchoResponse, error) {
return &pb.EchoResponse{ return &pb.EchoResponse{
Message: fmt.Sprintf("hello from localhost:%d", *port), Message: fmt.Sprintf("hello from localhost:%d", *port),
}, nil }, nil

View File

@ -55,7 +55,7 @@ type server struct {
pb.UnimplementedEchoServer pb.UnimplementedEchoServer
} }
func (s *server) UnaryEcho(ctx context.Context, in *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *server) UnaryEcho(_ context.Context, in *pb.EchoRequest) (*pb.EchoResponse, error) {
fmt.Printf("unary echoing message %q\n", in.Message) fmt.Printf("unary echoing message %q\n", in.Message)
return &pb.EchoResponse{Message: in.Message}, nil return &pb.EchoResponse{Message: in.Message}, nil
} }
@ -87,7 +87,7 @@ func valid(authorization []string) bool {
return token == "some-secret-token" return token == "some-secret-token"
} }
func unaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { func unaryInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
// authentication (token verification) // authentication (token verification)
md, ok := metadata.FromIncomingContext(ctx) md, ok := metadata.FromIncomingContext(ctx)
if !ok { if !ok {
@ -123,7 +123,7 @@ func newWrappedStream(s grpc.ServerStream) grpc.ServerStream {
return &wrappedStream{s} return &wrappedStream{s}
} }
func streamInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { func streamInterceptor(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
// authentication (token verification) // authentication (token verification)
md, ok := metadata.FromIncomingContext(ss.Context()) md, ok := metadata.FromIncomingContext(ss.Context())
if !ok { if !ok {

View File

@ -53,7 +53,7 @@ type server struct {
pb.UnimplementedEchoServer pb.UnimplementedEchoServer
} }
func (s *server) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *server) UnaryEcho(_ context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
return &pb.EchoResponse{Message: req.Message}, nil return &pb.EchoResponse{Message: req.Message}, nil
} }

View File

@ -91,7 +91,7 @@ func main() {
type exampleResolverBuilder struct{} type exampleResolverBuilder struct{}
func (*exampleResolverBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) { func (*exampleResolverBuilder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) {
r := &exampleResolver{ r := &exampleResolver{
target: target, target: target,
cc: cc, cc: cc,
@ -118,7 +118,7 @@ func (r *exampleResolver) start() {
} }
r.cc.UpdateState(resolver.State{Addresses: addrs}) r.cc.UpdateState(resolver.State{Addresses: addrs})
} }
func (*exampleResolver) ResolveNow(o resolver.ResolveNowOptions) {} func (*exampleResolver) ResolveNow(resolver.ResolveNowOptions) {}
func (*exampleResolver) Close() {} func (*exampleResolver) Close() {}
func init() { func init() {

View File

@ -40,7 +40,7 @@ type ecServer struct {
addr string addr string
} }
func (s *ecServer) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *ecServer) UnaryEcho(_ context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
return &pb.EchoResponse{Message: fmt.Sprintf("%s (from %s)", req.Message, s.addr)}, nil return &pb.EchoResponse{Message: fmt.Sprintf("%s (from %s)", req.Message, s.addr)}, nil
} }

View File

@ -43,7 +43,7 @@ type server struct {
pb.UnimplementedEchoServer pb.UnimplementedEchoServer
} }
func unaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) { func unaryInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
md, ok := metadata.FromIncomingContext(ctx) md, ok := metadata.FromIncomingContext(ctx)
if !ok { if !ok {
return nil, errMissingMetadata return nil, errMissingMetadata
@ -95,7 +95,7 @@ func (s *wrappedStream) Context() context.Context {
return s.ctx return s.ctx
} }
func streamInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { func streamInterceptor(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
md, ok := metadata.FromIncomingContext(ss.Context()) md, ok := metadata.FromIncomingContext(ss.Context())
if !ok { if !ok {
return errMissingMetadata return errMissingMetadata

View File

@ -40,7 +40,7 @@ type hwServer struct {
} }
// SayHello implements helloworld.GreeterServer // SayHello implements helloworld.GreeterServer
func (s *hwServer) SayHello(ctx context.Context, in *hwpb.HelloRequest) (*hwpb.HelloReply, error) { func (s *hwServer) SayHello(_ context.Context, in *hwpb.HelloRequest) (*hwpb.HelloReply, error) {
return &hwpb.HelloReply{Message: "Hello " + in.Name}, nil return &hwpb.HelloReply{Message: "Hello " + in.Name}, nil
} }
@ -48,7 +48,7 @@ type ecServer struct {
ecpb.UnimplementedEchoServer ecpb.UnimplementedEchoServer
} }
func (s *ecServer) UnaryEcho(ctx context.Context, req *ecpb.EchoRequest) (*ecpb.EchoResponse, error) { func (s *ecServer) UnaryEcho(_ context.Context, req *ecpb.EchoRequest) (*ecpb.EchoResponse, error) {
return &ecpb.EchoResponse{Message: req.Message}, nil return &ecpb.EchoResponse{Message: req.Message}, nil
} }

View File

@ -97,7 +97,7 @@ func main() {
// ResolverBuilder(https://godoc.org/google.golang.org/grpc/resolver#Builder). // ResolverBuilder(https://godoc.org/google.golang.org/grpc/resolver#Builder).
type exampleResolverBuilder struct{} type exampleResolverBuilder struct{}
func (*exampleResolverBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) { func (*exampleResolverBuilder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) {
r := &exampleResolver{ r := &exampleResolver{
target: target, target: target,
cc: cc, cc: cc,
@ -126,7 +126,7 @@ func (r *exampleResolver) start() {
} }
r.cc.UpdateState(resolver.State{Addresses: addrs}) r.cc.UpdateState(resolver.State{Addresses: addrs})
} }
func (*exampleResolver) ResolveNow(o resolver.ResolveNowOptions) {} func (*exampleResolver) ResolveNow(resolver.ResolveNowOptions) {}
func (*exampleResolver) Close() {} func (*exampleResolver) Close() {}
func init() { func init() {

View File

@ -37,7 +37,7 @@ type ecServer struct {
addr string addr string
} }
func (s *ecServer) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *ecServer) UnaryEcho(_ context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
return &pb.EchoResponse{Message: fmt.Sprintf("%s (from %s)", req.Message, s.addr)}, nil return &pb.EchoResponse{Message: fmt.Sprintf("%s (from %s)", req.Message, s.addr)}, nil
} }

View File

@ -45,7 +45,7 @@ type server struct {
} }
// SayHello implements helloworld.GreeterServer // SayHello implements helloworld.GreeterServer
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { func (s *server) SayHello(_ context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
log.Printf("Received: %v", in.GetName()) log.Printf("Received: %v", in.GetName())
return &pb.HelloReply{Message: "Hello " + in.GetName()}, nil return &pb.HelloReply{Message: "Hello " + in.GetName()}, nil
} }

View File

@ -45,7 +45,7 @@ type echoServer struct {
addr string addr string
} }
func (s *echoServer) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *echoServer) UnaryEcho(_ context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
return &pb.EchoResponse{Message: fmt.Sprintf("%s (from %s)", req.Message, s.addr)}, nil return &pb.EchoResponse{Message: fmt.Sprintf("%s (from %s)", req.Message, s.addr)}, nil
} }

View File

@ -82,7 +82,7 @@ func init() {
type orcaLBBuilder struct{} type orcaLBBuilder struct{}
func (orcaLBBuilder) Name() string { return "orca_example" } func (orcaLBBuilder) Name() string { return "orca_example" }
func (orcaLBBuilder) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer { func (orcaLBBuilder) Build(cc balancer.ClientConn, _ balancer.BuildOptions) balancer.Balancer {
return &orcaLB{cc: cc} return &orcaLB{cc: cc}
} }
@ -124,7 +124,7 @@ func (o *orcaLB) UpdateClientConnState(ccs balancer.ClientConnState) error {
func (o *orcaLB) ResolverError(error) {} func (o *orcaLB) ResolverError(error) {}
// TODO: unused; remove when no longer required. // TODO: unused; remove when no longer required.
func (o *orcaLB) UpdateSubConnState(sc balancer.SubConn, scs balancer.SubConnState) {} func (o *orcaLB) UpdateSubConnState(balancer.SubConn, balancer.SubConnState) {}
func (o *orcaLB) Close() {} func (o *orcaLB) Close() {}
@ -132,7 +132,7 @@ type picker struct {
sc balancer.SubConn sc balancer.SubConn
} }
func (p *picker) Pick(info balancer.PickInfo) (balancer.PickResult, error) { func (p *picker) Pick(balancer.PickInfo) (balancer.PickResult, error) {
return balancer.PickResult{ return balancer.PickResult{
SubConn: p.sc, SubConn: p.sc,
Done: func(di balancer.DoneInfo) { Done: func(di balancer.DoneInfo) {

View File

@ -41,7 +41,7 @@ type hwServer struct {
} }
// SayHello implements helloworld.GreeterServer // SayHello implements helloworld.GreeterServer
func (s *hwServer) SayHello(ctx context.Context, in *hwpb.HelloRequest) (*hwpb.HelloReply, error) { func (s *hwServer) SayHello(_ context.Context, in *hwpb.HelloRequest) (*hwpb.HelloReply, error) {
return &hwpb.HelloReply{Message: "Hello " + in.Name}, nil return &hwpb.HelloReply{Message: "Hello " + in.Name}, nil
} }
@ -49,7 +49,7 @@ type ecServer struct {
ecpb.UnimplementedEchoServer ecpb.UnimplementedEchoServer
} }
func (s *ecServer) UnaryEcho(ctx context.Context, req *ecpb.EchoRequest) (*ecpb.EchoResponse, error) { func (s *ecServer) UnaryEcho(_ context.Context, req *ecpb.EchoRequest) (*ecpb.EchoResponse, error) {
return &ecpb.EchoResponse{Message: req.Message}, nil return &ecpb.EchoResponse{Message: req.Message}, nil
} }

View File

@ -57,7 +57,7 @@ func (s *failingServer) maybeFailRequest() error {
return status.Errorf(codes.Unavailable, "maybeFailRequest: failing it") return status.Errorf(codes.Unavailable, "maybeFailRequest: failing it")
} }
func (s *failingServer) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *failingServer) UnaryEcho(_ context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
if err := s.maybeFailRequest(); err != nil { if err := s.maybeFailRequest(); err != nil {
log.Println("request failed count:", s.reqCounter) log.Println("request failed count:", s.reqCounter)
return nil, err return nil, err

View File

@ -40,7 +40,7 @@ type server struct {
echogrpc.UnimplementedEchoServer echogrpc.UnimplementedEchoServer
} }
func (s *server) UnaryEcho(ctx context.Context, req *echopb.EchoRequest) (*echopb.EchoResponse, error) { func (s *server) UnaryEcho(_ context.Context, req *echopb.EchoRequest) (*echopb.EchoResponse, error) {
time.Sleep(2 * time.Second) time.Sleep(2 * time.Second)
return &echopb.EchoResponse{Message: req.Message}, nil return &echopb.EchoResponse{Message: req.Message}, nil
} }

View File

@ -40,7 +40,7 @@ type server struct {
pb.UnimplementedEchoServer pb.UnimplementedEchoServer
} }
func (s *server) UnaryEcho(ctx context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) { func (s *server) UnaryEcho(_ context.Context, req *pb.EchoRequest) (*pb.EchoResponse, error) {
return &pb.EchoResponse{Message: req.Message}, nil return &pb.EchoResponse{Message: req.Message}, nil
} }

View File

@ -51,7 +51,7 @@ type server struct {
} }
// SayHello implements helloworld.GreeterServer interface. // SayHello implements helloworld.GreeterServer interface.
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { func (s *server) SayHello(_ context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
log.Printf("Received: %v", in.GetName()) log.Printf("Received: %v", in.GetName())
return &pb.HelloReply{Message: "Hello " + in.GetName() + ", from " + s.serverName}, nil return &pb.HelloReply{Message: "Hello " + in.GetName() + ", from " + s.serverName}, nil
} }

View File

@ -40,7 +40,7 @@ type server struct {
} }
// SayHello implements helloworld.GreeterServer // SayHello implements helloworld.GreeterServer
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { func (s *server) SayHello(_ context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
log.Printf("Received: %v", in.GetName()) log.Printf("Received: %v", in.GetName())
return &pb.HelloReply{Message: "Hello " + in.GetName()}, nil return &pb.HelloReply{Message: "Hello " + in.GetName()}, nil
} }

View File

@ -60,7 +60,7 @@ type routeGuideServer struct {
} }
// GetFeature returns the feature at the given point. // GetFeature returns the feature at the given point.
func (s *routeGuideServer) GetFeature(ctx context.Context, point *pb.Point) (*pb.Feature, error) { func (s *routeGuideServer) GetFeature(_ context.Context, point *pb.Point) (*pb.Feature, error) {
for _, feature := range s.savedFeatures { for _, feature := range s.savedFeatures {
if proto.Equal(feature.Location, point) { if proto.Equal(feature.Location, point) {
return feature, nil return feature, nil

View File

@ -134,7 +134,7 @@ func (s) TestClientRPCEventsLogAll(t *testing.T) {
newLoggingExporter = ne newLoggingExporter = ne
}(newLoggingExporter) }(newLoggingExporter)
newLoggingExporter = func(ctx context.Context, config *config) (loggingExporter, error) { newLoggingExporter = func(context.Context, *config) (loggingExporter, error) {
return fle, nil return fle, nil
} }
@ -157,7 +157,7 @@ func (s) TestClientRPCEventsLogAll(t *testing.T) {
defer cleanup() defer cleanup()
ss := &stubserver.StubServer{ ss := &stubserver.StubServer{
UnaryCallF: func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { UnaryCallF: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{}, nil return &testpb.SimpleResponse{}, nil
}, },
FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error { FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
@ -344,7 +344,7 @@ func (s) TestServerRPCEventsLogAll(t *testing.T) {
newLoggingExporter = ne newLoggingExporter = ne
}(newLoggingExporter) }(newLoggingExporter)
newLoggingExporter = func(ctx context.Context, config *config) (loggingExporter, error) { newLoggingExporter = func(context.Context, *config) (loggingExporter, error) {
return fle, nil return fle, nil
} }
@ -367,7 +367,7 @@ func (s) TestServerRPCEventsLogAll(t *testing.T) {
defer cleanup() defer cleanup()
ss := &stubserver.StubServer{ ss := &stubserver.StubServer{
UnaryCallF: func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { UnaryCallF: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{}, nil return &testpb.SimpleResponse{}, nil
}, },
FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error { FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
@ -558,7 +558,7 @@ func (s) TestBothClientAndServerRPCEvents(t *testing.T) {
newLoggingExporter = ne newLoggingExporter = ne
}(newLoggingExporter) }(newLoggingExporter)
newLoggingExporter = func(ctx context.Context, config *config) (loggingExporter, error) { newLoggingExporter = func(context.Context, *config) (loggingExporter, error) {
return fle, nil return fle, nil
} }

View File

@ -369,7 +369,7 @@ func (s) TestOpenCensusIntegration(t *testing.T) {
newExporter = ne newExporter = ne
}(newExporter) }(newExporter)
newExporter = func(config *config) (tracingMetricsExporter, error) { newExporter = func(*config) (tracingMetricsExporter, error) {
return fe, nil return fe, nil
} }
@ -387,7 +387,7 @@ func (s) TestOpenCensusIntegration(t *testing.T) {
defer cleanup() defer cleanup()
ss := &stubserver.StubServer{ ss := &stubserver.StubServer{
UnaryCallF: func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { UnaryCallF: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{}, nil return &testpb.SimpleResponse{}, nil
}, },
FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error { FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
@ -569,7 +569,7 @@ func (s) TestLoggingLinkedWithTraceClientSide(t *testing.T) {
newLoggingExporter = oldNewLoggingExporter newLoggingExporter = oldNewLoggingExporter
}() }()
newLoggingExporter = func(ctx context.Context, config *config) (loggingExporter, error) { newLoggingExporter = func(context.Context, *config) (loggingExporter, error) {
return fle, nil return fle, nil
} }
@ -584,7 +584,7 @@ func (s) TestLoggingLinkedWithTraceClientSide(t *testing.T) {
newExporter = oldNewExporter newExporter = oldNewExporter
}() }()
newExporter = func(config *config) (tracingMetricsExporter, error) { newExporter = func(*config) (tracingMetricsExporter, error) {
return fe, nil return fe, nil
} }
@ -610,7 +610,7 @@ func (s) TestLoggingLinkedWithTraceClientSide(t *testing.T) {
} }
defer cleanup() defer cleanup()
ss := &stubserver.StubServer{ ss := &stubserver.StubServer{
UnaryCallF: func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { UnaryCallF: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{}, nil return &testpb.SimpleResponse{}, nil
}, },
FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error { FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
@ -711,7 +711,7 @@ func (s) TestLoggingLinkedWithTraceServerSide(t *testing.T) {
newLoggingExporter = oldNewLoggingExporter newLoggingExporter = oldNewLoggingExporter
}() }()
newLoggingExporter = func(ctx context.Context, config *config) (loggingExporter, error) { newLoggingExporter = func(context.Context, *config) (loggingExporter, error) {
return fle, nil return fle, nil
} }
@ -726,7 +726,7 @@ func (s) TestLoggingLinkedWithTraceServerSide(t *testing.T) {
newExporter = oldNewExporter newExporter = oldNewExporter
}() }()
newExporter = func(config *config) (tracingMetricsExporter, error) { newExporter = func(*config) (tracingMetricsExporter, error) {
return fe, nil return fe, nil
} }
@ -752,7 +752,7 @@ func (s) TestLoggingLinkedWithTraceServerSide(t *testing.T) {
} }
defer cleanup() defer cleanup()
ss := &stubserver.StubServer{ ss := &stubserver.StubServer{
UnaryCallF: func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { UnaryCallF: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{}, nil return &testpb.SimpleResponse{}, nil
}, },
FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error { FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
@ -855,7 +855,7 @@ func (s) TestLoggingLinkedWithTrace(t *testing.T) {
newLoggingExporter = oldNewLoggingExporter newLoggingExporter = oldNewLoggingExporter
}() }()
newLoggingExporter = func(ctx context.Context, config *config) (loggingExporter, error) { newLoggingExporter = func(context.Context, *config) (loggingExporter, error) {
return fle, nil return fle, nil
} }
@ -870,7 +870,7 @@ func (s) TestLoggingLinkedWithTrace(t *testing.T) {
newExporter = oldNewExporter newExporter = oldNewExporter
}() }()
newExporter = func(config *config) (tracingMetricsExporter, error) { newExporter = func(*config) (tracingMetricsExporter, error) {
return fe, nil return fe, nil
} }
@ -903,7 +903,7 @@ func (s) TestLoggingLinkedWithTrace(t *testing.T) {
} }
defer cleanup() defer cleanup()
ss := &stubserver.StubServer{ ss := &stubserver.StubServer{
UnaryCallF: func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { UnaryCallF: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{}, nil return &testpb.SimpleResponse{}, nil
}, },
FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error { FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {

View File

@ -81,7 +81,7 @@ func (l *LoggerWrapper) Errorf(format string, args ...any) {
} }
// V reports whether verbosity level l is at least the requested verbose level. // V reports whether verbosity level l is at least the requested verbose level.
func (*LoggerWrapper) V(l int) bool { func (*LoggerWrapper) V(int) bool {
// Returns true for all verbose level. // Returns true for all verbose level.
return true return true
} }

View File

@ -47,7 +47,7 @@ func (s) TestClientHealthCheckBackoff(t *testing.T) {
} }
oldBackoffFunc := backoffFunc oldBackoffFunc := backoffFunc
backoffFunc = func(ctx context.Context, retries int) bool { backoffFunc = func(_ context.Context, retries int) bool {
got = append(got, time.Duration(retries+1)*time.Second) got = append(got, time.Duration(retries+1)*time.Second)
return true return true
} }

View File

@ -51,7 +51,7 @@ func NewServer() *Server {
} }
// Check implements `service Health`. // Check implements `service Health`.
func (s *Server) Check(ctx context.Context, in *healthpb.HealthCheckRequest) (*healthpb.HealthCheckResponse, error) { func (s *Server) Check(_ context.Context, in *healthpb.HealthCheckRequest) (*healthpb.HealthCheckResponse, error) {
s.mu.RLock() s.mu.RLock()
defer s.mu.RUnlock() defer s.mu.RUnlock()
if servingStatus, ok := s.statusMap[in.Service]; ok { if servingStatus, ok := s.statusMap[in.Service]; ok {

View File

@ -666,7 +666,7 @@ func (s) TestPendingReplacedByAnotherPending(t *testing.T) {
// Picker which never errors here for test purposes (can fill up tests further up with this) // Picker which never errors here for test purposes (can fill up tests further up with this)
type neverErrPicker struct{} type neverErrPicker struct{}
func (p *neverErrPicker) Pick(info balancer.PickInfo) (balancer.PickResult, error) { func (p *neverErrPicker) Pick(balancer.PickInfo) (balancer.PickResult, error) {
return balancer.PickResult{}, nil return balancer.PickResult{}, nil
} }
@ -836,7 +836,7 @@ const buildCallbackBalName = "callbackInBuildBalancer"
type mockBalancerBuilder1 struct{} type mockBalancerBuilder1 struct{}
func (mockBalancerBuilder1) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer { func (mockBalancerBuilder1) Build(cc balancer.ClientConn, _ balancer.BuildOptions) balancer.Balancer {
return &mockBalancer{ return &mockBalancer{
ccsCh: testutils.NewChannel(), ccsCh: testutils.NewChannel(),
scStateCh: testutils.NewChannel(), scStateCh: testutils.NewChannel(),
@ -969,7 +969,7 @@ func (mb1 *mockBalancer) updateAddresses(sc balancer.SubConn, addrs []resolver.A
type mockBalancerBuilder2 struct{} type mockBalancerBuilder2 struct{}
func (mockBalancerBuilder2) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer { func (mockBalancerBuilder2) Build(cc balancer.ClientConn, _ balancer.BuildOptions) balancer.Balancer {
return &mockBalancer{ return &mockBalancer{
ccsCh: testutils.NewChannel(), ccsCh: testutils.NewChannel(),
scStateCh: testutils.NewChannel(), scStateCh: testutils.NewChannel(),
@ -985,7 +985,7 @@ func (mockBalancerBuilder2) Name() string {
type verifyBalancerBuilder struct{} type verifyBalancerBuilder struct{}
func (verifyBalancerBuilder) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer { func (verifyBalancerBuilder) Build(cc balancer.ClientConn, _ balancer.BuildOptions) balancer.Balancer {
return &verifyBalancer{ return &verifyBalancer{
closed: grpcsync.NewEvent(), closed: grpcsync.NewEvent(),
cc: cc, cc: cc,
@ -1006,11 +1006,11 @@ type verifyBalancer struct {
t *testing.T t *testing.T
} }
func (vb *verifyBalancer) UpdateClientConnState(ccs balancer.ClientConnState) error { func (vb *verifyBalancer) UpdateClientConnState(balancer.ClientConnState) error {
return nil return nil
} }
func (vb *verifyBalancer) ResolverError(err error) {} func (vb *verifyBalancer) ResolverError(error) {}
func (vb *verifyBalancer) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) { func (vb *verifyBalancer) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) {
panic(fmt.Sprintf("UpdateSubConnState(%v, %+v) called unexpectedly", sc, state)) panic(fmt.Sprintf("UpdateSubConnState(%v, %+v) called unexpectedly", sc, state))
@ -1034,7 +1034,7 @@ func (vb *verifyBalancer) newSubConn(addrs []resolver.Address, opts balancer.New
type buildCallbackBalancerBuilder struct{} type buildCallbackBalancerBuilder struct{}
func (buildCallbackBalancerBuilder) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer { func (buildCallbackBalancerBuilder) Build(cc balancer.ClientConn, _ balancer.BuildOptions) balancer.Balancer {
b := &buildCallbackBal{ b := &buildCallbackBal{
cc: cc, cc: cc,
closeCh: testutils.NewChannel(), closeCh: testutils.NewChannel(),
@ -1062,11 +1062,11 @@ type buildCallbackBal struct {
closeCh *testutils.Channel closeCh *testutils.Channel
} }
func (bcb *buildCallbackBal) UpdateClientConnState(ccs balancer.ClientConnState) error { func (bcb *buildCallbackBal) UpdateClientConnState(balancer.ClientConnState) error {
return nil return nil
} }
func (bcb *buildCallbackBal) ResolverError(err error) {} func (bcb *buildCallbackBal) ResolverError(error) {}
func (bcb *buildCallbackBal) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) { func (bcb *buildCallbackBal) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) {
panic(fmt.Sprintf("UpdateSubConnState(%v, %+v) called unexpectedly", sc, state)) panic(fmt.Sprintf("UpdateSubConnState(%v, %+v) called unexpectedly", sc, state))

View File

@ -106,7 +106,7 @@ func (ml *TruncatingMethodLogger) Build(c LogEntryConfig) *binlogpb.GrpcLogEntry
} }
// Log creates a proto binary log entry, and logs it to the sink. // Log creates a proto binary log entry, and logs it to the sink.
func (ml *TruncatingMethodLogger) Log(ctx context.Context, c LogEntryConfig) { func (ml *TruncatingMethodLogger) Log(_ context.Context, c LogEntryConfig) {
ml.sink.Write(ml.Build(c)) ml.sink.Write(ml.Build(c))
} }

View File

@ -35,13 +35,13 @@ type SocketOptionData struct {
// Getsockopt defines the function to get socket options requested by channelz. // Getsockopt defines the function to get socket options requested by channelz.
// It is to be passed to syscall.RawConn.Control(). // It is to be passed to syscall.RawConn.Control().
// Windows OS doesn't support Socket Option // Windows OS doesn't support Socket Option
func (s *SocketOptionData) Getsockopt(fd uintptr) { func (s *SocketOptionData) Getsockopt(uintptr) {
once.Do(func() { once.Do(func() {
logger.Warning("Channelz: socket options are not supported on non-linux environments") logger.Warning("Channelz: socket options are not supported on non-linux environments")
}) })
} }
// GetSocketOption gets the socket option info of the conn. // GetSocketOption gets the socket option info of the conn.
func GetSocketOption(c any) *SocketOptionData { func GetSocketOption(any) *SocketOptionData {
return nil return nil
} }

View File

@ -32,39 +32,39 @@ func Test(t *testing.T) {
RunSubTests(t, s{}) RunSubTests(t, s{})
} }
func (s) TestInfo(t *testing.T) { func (s) TestInfo(*testing.T) {
grpclog.Info("Info", "message.") grpclog.Info("Info", "message.")
} }
func (s) TestInfoln(t *testing.T) { func (s) TestInfoln(*testing.T) {
grpclog.Infoln("Info", "message.") grpclog.Infoln("Info", "message.")
} }
func (s) TestInfof(t *testing.T) { func (s) TestInfof(*testing.T) {
grpclog.Infof("%v %v.", "Info", "message") grpclog.Infof("%v %v.", "Info", "message")
} }
func (s) TestInfoDepth(t *testing.T) { func (s) TestInfoDepth(*testing.T) {
grpclog.InfoDepth(0, "Info", "depth", "message.") grpclog.InfoDepth(0, "Info", "depth", "message.")
} }
func (s) TestWarning(t *testing.T) { func (s) TestWarning(*testing.T) {
grpclog.Warning("Warning", "message.") grpclog.Warning("Warning", "message.")
} }
func (s) TestWarningln(t *testing.T) { func (s) TestWarningln(*testing.T) {
grpclog.Warningln("Warning", "message.") grpclog.Warningln("Warning", "message.")
} }
func (s) TestWarningf(t *testing.T) { func (s) TestWarningf(*testing.T) {
grpclog.Warningf("%v %v.", "Warning", "message") grpclog.Warningf("%v %v.", "Warning", "message")
} }
func (s) TestWarningDepth(t *testing.T) { func (s) TestWarningDepth(*testing.T) {
grpclog.WarningDepth(0, "Warning", "depth", "message.") grpclog.WarningDepth(0, "Warning", "depth", "message.")
} }
func (s) TestError(t *testing.T) { func (s) TestError(*testing.T) {
const numErrors = 10 const numErrors = 10
TLogger.ExpectError("Expected error") TLogger.ExpectError("Expected error")
TLogger.ExpectError("Expected ln error") TLogger.ExpectError("Expected ln error")

View File

@ -30,7 +30,7 @@ type testLogger struct {
errors []string errors []string
} }
func (e *testLogger) Logf(format string, args ...any) { func (e *testLogger) Logf(string, ...any) {
} }
func (e *testLogger) Errorf(format string, args ...any) { func (e *testLogger) Errorf(format string, args ...any) {

View File

@ -55,7 +55,7 @@ func (r *passthroughResolver) start() {
r.cc.UpdateState(resolver.State{Addresses: []resolver.Address{{Addr: r.target.Endpoint()}}}) r.cc.UpdateState(resolver.State{Addresses: []resolver.Address{{Addr: r.target.Endpoint()}}})
} }
func (*passthroughResolver) ResolveNow(o resolver.ResolveNowOptions) {} func (*passthroughResolver) ResolveNow(resolver.ResolveNowOptions) {}
func (*passthroughResolver) Close() {} func (*passthroughResolver) Close() {}

View File

@ -58,20 +58,20 @@ func GetRusage() *Rusage {
// CPUTimeDiff returns the differences of user CPU time and system CPU time used // CPUTimeDiff returns the differences of user CPU time and system CPU time used
// between two Rusage structs. It a no-op function for non-linux environments. // between two Rusage structs. It a no-op function for non-linux environments.
func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) { func CPUTimeDiff(*Rusage, *Rusage) (float64, float64) {
log() log()
return 0, 0 return 0, 0
} }
// SetTCPUserTimeout is a no-op function under non-linux environments. // SetTCPUserTimeout is a no-op function under non-linux environments.
func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error { func SetTCPUserTimeout(net.Conn, time.Duration) error {
log() log()
return nil return nil
} }
// GetTCPUserTimeout is a no-op function under non-linux environments. // GetTCPUserTimeout is a no-op function under non-linux environments.
// A negative return value indicates the operation is not supported // A negative return value indicates the operation is not supported
func GetTCPUserTimeout(conn net.Conn) (int, error) { func GetTCPUserTimeout(net.Conn) (int, error) {
log() log()
return -1, nil return -1, nil
} }

View File

@ -379,7 +379,7 @@ type TestConstPicker struct {
} }
// Pick returns the const SubConn or the error. // Pick returns the const SubConn or the error.
func (tcp *TestConstPicker) Pick(info balancer.PickInfo) (balancer.PickResult, error) { func (tcp *TestConstPicker) Pick(balancer.PickInfo) (balancer.PickResult, error) {
if tcp.Err != nil { if tcp.Err != nil {
return balancer.PickResult{}, tcp.Err return balancer.PickResult{}, tcp.Err
} }

View File

@ -53,7 +53,7 @@ func SetupFakeRLSServer(t *testing.T, lis net.Listener, opts ...grpc.ServerOptio
t.Logf("Started fake RLS server at %q", s.Address) t.Logf("Started fake RLS server at %q", s.Address)
ch := make(chan struct{}, 1) ch := make(chan struct{}, 1)
s.SetRequestCallback(func(request *rlspb.RouteLookupRequest) { s.SetRequestCallback(func(*rlspb.RouteLookupRequest) {
select { select {
case ch <- struct{}{}: case ch <- struct{}{}:
default: default:

View File

@ -333,7 +333,7 @@ func (ht *serverHandlerTransport) writeCustomHeaders(s *Stream) {
s.hdrMu.Unlock() s.hdrMu.Unlock()
} }
func (ht *serverHandlerTransport) Write(s *Stream, hdr []byte, data mem.BufferSlice, opts *Options) error { func (ht *serverHandlerTransport) Write(s *Stream, hdr []byte, data mem.BufferSlice, _ *Options) error {
// Always take a reference because otherwise there is no guarantee the data will // Always take a reference because otherwise there is no guarantee the data will
// be available after this function returns. This is what callers to Write // be available after this function returns. This is what callers to Write
// expect. // expect.
@ -475,7 +475,7 @@ func (ht *serverHandlerTransport) IncrMsgSent() {}
func (ht *serverHandlerTransport) IncrMsgRecv() {} func (ht *serverHandlerTransport) IncrMsgRecv() {}
func (ht *serverHandlerTransport) Drain(debugData string) { func (ht *serverHandlerTransport) Drain(string) {
panic("Drain() is not implemented") panic("Drain() is not implemented")
} }

View File

@ -138,7 +138,7 @@ func (s) TestHandlerTransport_NewServerHandlerTransport(t *testing.T) {
Path: "/service/foo.bar", Path: "/service/foo.bar",
}, },
}, },
check: func(t *serverHandlerTransport, tt *testCase) error { check: func(t *serverHandlerTransport, _ *testCase) error {
if !t.timeoutSet { if !t.timeoutSet {
return errors.New("timeout not set") return errors.New("timeout not set")
} }
@ -179,7 +179,7 @@ func (s) TestHandlerTransport_NewServerHandlerTransport(t *testing.T) {
Path: "/service/foo.bar", Path: "/service/foo.bar",
}, },
}, },
check: func(ht *serverHandlerTransport, tt *testCase) error { check: func(ht *serverHandlerTransport, _ *testCase) error {
want := metadata.MD{ want := metadata.MD{
"meta-bar": {"bar-val1", "bar-val2"}, "meta-bar": {"bar-val1", "bar-val2"},
"user-agent": {"x/y a/b"}, "user-agent": {"x/y a/b"},

View File

@ -772,7 +772,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
hdr := &headerFrame{ hdr := &headerFrame{
hf: headerFields, hf: headerFields,
endStream: false, endStream: false,
initStream: func(id uint32) error { initStream: func(uint32) error {
t.mu.Lock() t.mu.Lock()
// TODO: handle transport closure in loopy instead and remove this // TODO: handle transport closure in loopy instead and remove this
// initStream is never called when transport is draining. // initStream is never called when transport is draining.

View File

@ -1117,7 +1117,7 @@ func (t *http2Server) WriteStatus(s *Stream, st *status.Status) error {
// Write converts the data into HTTP2 data frame and sends it out. Non-nil error // Write converts the data into HTTP2 data frame and sends it out. Non-nil error
// is returns if it fails (e.g., framing error, transport error). // is returns if it fails (e.g., framing error, transport error).
func (t *http2Server) Write(s *Stream, hdr []byte, data mem.BufferSlice, opts *Options) error { func (t *http2Server) Write(s *Stream, hdr []byte, data mem.BufferSlice, _ *Options) error {
reader := data.Reader() reader := data.Reader()
if !s.isHeaderSent() { // Headers haven't been written yet. if !s.isHeaderSent() { // Headers haven't been written yet.

View File

@ -159,7 +159,7 @@ func testHTTPConnect(t *testing.T, args testArgs) {
}() }()
// Overwrite the function in the test and restore them in defer. // Overwrite the function in the test and restore them in defer.
hpfe := func(req *http.Request) (*url.URL, error) { hpfe := func(*http.Request) (*url.URL, error) {
return args.proxyURLModify(&url.URL{Host: plis.Addr().String()}), nil return args.proxyURLModify(&url.URL{Host: plis.Addr().String()}), nil
} }
defer overwrite(hpfe)() defer overwrite(hpfe)()

View File

@ -117,7 +117,7 @@ const (
pingpong pingpong
) )
func (h *testStreamHandler) handleStreamAndNotify(s *Stream) { func (h *testStreamHandler) handleStreamAndNotify(*Stream) {
if h.notify == nil { if h.notify == nil {
return return
} }
@ -2423,7 +2423,7 @@ type attrTransportCreds struct {
attr *attributes.Attributes attr *attributes.Attributes
} }
func (ac *attrTransportCreds) ClientHandshake(ctx context.Context, addr string, rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { func (ac *attrTransportCreds) ClientHandshake(ctx context.Context, _ string, rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
ai := credentials.ClientHandshakeInfoFromContext(ctx) ai := credentials.ClientHandshakeInfoFromContext(ctx)
ac.attr = ai.Attributes ac.attr = ai.Attributes
return rawConn, nil, nil return rawConn, nil, nil

View File

@ -244,7 +244,7 @@ func (am *andMatcher) match(data *rpcData) bool {
type alwaysMatcher struct { type alwaysMatcher struct {
} }
func (am *alwaysMatcher) match(data *rpcData) bool { func (am *alwaysMatcher) match(*rpcData) bool {
return true return true
} }

View File

@ -1812,15 +1812,15 @@ func (sts *ServerTransportStreamWithMethod) Method() string {
return sts.method return sts.method
} }
func (sts *ServerTransportStreamWithMethod) SetHeader(md metadata.MD) error { func (sts *ServerTransportStreamWithMethod) SetHeader(metadata.MD) error {
return nil return nil
} }
func (sts *ServerTransportStreamWithMethod) SendHeader(md metadata.MD) error { func (sts *ServerTransportStreamWithMethod) SendHeader(metadata.MD) error {
return nil return nil
} }
func (sts *ServerTransportStreamWithMethod) SetTrailer(md metadata.MD) error { func (sts *ServerTransportStreamWithMethod) SetTrailer(metadata.MD) error {
return nil return nil
} }
@ -1844,11 +1844,11 @@ type TestAuditLoggerBufferConfig struct {
audit.LoggerConfig audit.LoggerConfig
} }
func (b *TestAuditLoggerBufferBuilder) ParseLoggerConfig(configJSON json.RawMessage) (config audit.LoggerConfig, err error) { func (b *TestAuditLoggerBufferBuilder) ParseLoggerConfig(json.RawMessage) (config audit.LoggerConfig, err error) {
return TestAuditLoggerBufferConfig{}, nil return TestAuditLoggerBufferConfig{}, nil
} }
func (b *TestAuditLoggerBufferBuilder) Build(config audit.LoggerConfig) audit.Logger { func (b *TestAuditLoggerBufferBuilder) Build(audit.LoggerConfig) audit.Logger {
return &TestAuditLoggerBuffer{auditEvents: &b.auditEvents} return &TestAuditLoggerBuffer{auditEvents: &b.auditEvents}
} }
@ -1885,7 +1885,7 @@ func (b TestAuditLoggerCustomConfigBuilder) ParseLoggerConfig(configJSON json.Ra
return c, nil return c, nil
} }
func (b *TestAuditLoggerCustomConfigBuilder) Build(config audit.LoggerConfig) audit.Logger { func (b *TestAuditLoggerCustomConfigBuilder) Build(audit.LoggerConfig) audit.Logger {
return &TestAuditLoggerCustomConfig{} return &TestAuditLoggerCustomConfig{}
} }

View File

@ -37,7 +37,7 @@ func init() {
type orcabb struct{} type orcabb struct{}
func (orcabb) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer { func (orcabb) Build(cc balancer.ClientConn, _ balancer.BuildOptions) balancer.Balancer {
return &orcab{cc: cc} return &orcab{cc: cc}
} }

View File

@ -173,7 +173,7 @@ func newMetricsServer() *server {
} }
// GetAllGauges returns all gauges. // GetAllGauges returns all gauges.
func (s *server) GetAllGauges(in *metricspb.EmptyMessage, stream metricspb.MetricsService_GetAllGaugesServer) error { func (s *server) GetAllGauges(_ *metricspb.EmptyMessage, stream metricspb.MetricsService_GetAllGaugesServer) error {
s.mutex.RLock() s.mutex.RLock()
defer s.mutex.RUnlock() defer s.mutex.RUnlock()
@ -186,7 +186,7 @@ func (s *server) GetAllGauges(in *metricspb.EmptyMessage, stream metricspb.Metri
} }
// GetGauge returns the gauge for the given name. // GetGauge returns the gauge for the given name.
func (s *server) GetGauge(ctx context.Context, in *metricspb.GaugeRequest) (*metricspb.GaugeResponse, error) { func (s *server) GetGauge(_ context.Context, in *metricspb.GaugeRequest) (*metricspb.GaugeResponse, error) {
s.mutex.RLock() s.mutex.RLock()
defer s.mutex.RUnlock() defer s.mutex.RUnlock()

View File

@ -801,7 +801,7 @@ func NewTestServer(opts ...NewTestServerOptions) testgrpc.TestServiceServer {
return &testServer{} return &testServer{}
} }
func (s *testServer) EmptyCall(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) { func (s *testServer) EmptyCall(context.Context, *testpb.Empty) (*testpb.Empty, error) {
return new(testpb.Empty), nil return new(testpb.Empty), nil
} }

View File

@ -279,7 +279,7 @@ func (s *statsService) GetClientStats(ctx context.Context, in *testpb.LoadBalanc
} }
} }
func (s *statsService) GetClientAccumulatedStats(ctx context.Context, in *testpb.LoadBalancerAccumulatedStatsRequest) (*testpb.LoadBalancerAccumulatedStatsResponse, error) { func (s *statsService) GetClientAccumulatedStats(context.Context, *testpb.LoadBalancerAccumulatedStatsRequest) (*testpb.LoadBalancerAccumulatedStatsResponse, error) {
return accStats.buildResp(), nil return accStats.buildResp(), nil
} }
@ -287,7 +287,7 @@ type configureService struct {
testgrpc.UnimplementedXdsUpdateClientConfigureServiceServer testgrpc.UnimplementedXdsUpdateClientConfigureServiceServer
} }
func (s *configureService) Configure(ctx context.Context, in *testpb.ClientConfigureRequest) (*testpb.ClientConfigureResponse, error) { func (s *configureService) Configure(_ context.Context, in *testpb.ClientConfigureRequest) (*testpb.ClientConfigureResponse, error) {
rpcsToMD := make(map[testpb.ClientConfigureRequest_RpcType][]string) rpcsToMD := make(map[testpb.ClientConfigureRequest_RpcType][]string)
for _, typ := range in.GetTypes() { for _, typ := range in.GetTypes() {
rpcsToMD[typ] = nil rpcsToMD[typ] = nil

View File

@ -58,7 +58,7 @@ func (s) TestCustomLB(t *testing.T) {
// Setup a backend which verifies the expected rpc-behavior metadata is // Setup a backend which verifies the expected rpc-behavior metadata is
// present in the request. // present in the request.
backend := &stubserver.StubServer{ backend := &stubserver.StubServer{
UnaryCallF: func(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) { UnaryCallF: func(ctx context.Context, _ *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
md, ok := metadata.FromIncomingContext(ctx) md, ok := metadata.FromIncomingContext(ctx)
if !ok { if !ok {
errCh.Send(errors.New("failed to receive metadata")) errCh.Send(errors.New("failed to receive metadata"))

View File

@ -224,11 +224,11 @@ func (e emptyBuffer) Len() int {
return 0 return 0
} }
func (e emptyBuffer) split(n int) (left, right Buffer) { func (e emptyBuffer) split(int) (left, right Buffer) {
return e, e return e, e
} }
func (e emptyBuffer) read(buf []byte) (int, Buffer) { func (e emptyBuffer) read([]byte) (int, Buffer) {
return 0, e return 0, e
} }

View File

@ -156,7 +156,7 @@ func unaryInt(smp ServerMetricsProvider) func(ctx context.Context, req any, _ *g
} }
func streamInt(smp ServerMetricsProvider) func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { func streamInt(smp ServerMetricsProvider) func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
return func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { return func(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
// We don't allocate the metric recorder here. It will be allocated the // We don't allocate the metric recorder here. It will be allocated the
// first time the user calls CallMetricsRecorderFromContext(). // first time the user calls CallMetricsRecorderFromContext().
rw := &recorderWrapper{smp: smp} rw := &recorderWrapper{smp: smp}

View File

@ -56,7 +56,7 @@ type testingPicker struct {
maxCalled int64 maxCalled int64
} }
func (p *testingPicker) Pick(info balancer.PickInfo) (balancer.PickResult, error) { func (p *testingPicker) Pick(balancer.PickInfo) (balancer.PickResult, error) {
if atomic.AddInt64(&p.maxCalled, -1) < 0 { if atomic.AddInt64(&p.maxCalled, -1) < 0 {
return balancer.PickResult{}, fmt.Errorf("pick called to many times (> goroutineCount)") return balancer.PickResult{}, fmt.Errorf("pick called to many times (> goroutineCount)")
} }

View File

@ -99,7 +99,7 @@ func getProfilingServerInstance() *profilingServer {
return profilingServerInstance return profilingServerInstance
} }
func (s *profilingServer) Enable(ctx context.Context, req *ppb.EnableRequest) (*ppb.EnableResponse, error) { func (s *profilingServer) Enable(_ context.Context, req *ppb.EnableRequest) (*ppb.EnableResponse, error) {
if req.Enabled { if req.Enabled {
logger.Infof("profilingServer: Enable: enabling profiling") logger.Infof("profilingServer: Enable: enabling profiling")
} else { } else {
@ -133,7 +133,7 @@ func statToProtoStat(stat *profiling.Stat) *ppb.Stat {
return protoStat return protoStat
} }
func (s *profilingServer) GetStreamStats(ctx context.Context, req *ppb.GetStreamStatsRequest) (*ppb.GetStreamStatsResponse, error) { func (s *profilingServer) GetStreamStats(context.Context, *ppb.GetStreamStatsRequest) (*ppb.GetStreamStatsResponse, error) {
// Since the drain operation is destructive, only one client request should // Since the drain operation is destructive, only one client request should
// be served at a time. // be served at a time.
logger.Infof("profilingServer: GetStreamStats: processing request") logger.Infof("profilingServer: GetStreamStats: processing request")

View File

@ -55,7 +55,7 @@ func (s) TestResolverCaseSensitivity(t *testing.T) {
// into a loopback IP (v4 or v6) address. // into a loopback IP (v4 or v6) address.
target := "caseTest:///localhost:1234" target := "caseTest:///localhost:1234"
addrCh := make(chan string, 1) addrCh := make(chan string, 1)
customDialer := func(ctx context.Context, addr string) (net.Conn, error) { customDialer := func(_ context.Context, addr string) (net.Conn, error) {
select { select {
case addrCh <- addr: case addrCh <- addr:
default: default:

View File

@ -220,8 +220,8 @@ type HeaderCallOption struct {
HeaderAddr *metadata.MD HeaderAddr *metadata.MD
} }
func (o HeaderCallOption) before(c *callInfo) error { return nil } func (o HeaderCallOption) before(*callInfo) error { return nil }
func (o HeaderCallOption) after(c *callInfo, attempt *csAttempt) { func (o HeaderCallOption) after(_ *callInfo, attempt *csAttempt) {
*o.HeaderAddr, _ = attempt.s.Header() *o.HeaderAddr, _ = attempt.s.Header()
} }
@ -242,8 +242,8 @@ type TrailerCallOption struct {
TrailerAddr *metadata.MD TrailerAddr *metadata.MD
} }
func (o TrailerCallOption) before(c *callInfo) error { return nil } func (o TrailerCallOption) before(*callInfo) error { return nil }
func (o TrailerCallOption) after(c *callInfo, attempt *csAttempt) { func (o TrailerCallOption) after(_ *callInfo, attempt *csAttempt) {
*o.TrailerAddr = attempt.s.Trailer() *o.TrailerAddr = attempt.s.Trailer()
} }
@ -264,8 +264,8 @@ type PeerCallOption struct {
PeerAddr *peer.Peer PeerAddr *peer.Peer
} }
func (o PeerCallOption) before(c *callInfo) error { return nil } func (o PeerCallOption) before(*callInfo) error { return nil }
func (o PeerCallOption) after(c *callInfo, attempt *csAttempt) { func (o PeerCallOption) after(_ *callInfo, attempt *csAttempt) {
if x, ok := peer.FromContext(attempt.s.Context()); ok { if x, ok := peer.FromContext(attempt.s.Context()); ok {
*o.PeerAddr = *x *o.PeerAddr = *x
} }
@ -304,7 +304,7 @@ func (o FailFastCallOption) before(c *callInfo) error {
c.failFast = o.FailFast c.failFast = o.FailFast
return nil return nil
} }
func (o FailFastCallOption) after(c *callInfo, attempt *csAttempt) {} func (o FailFastCallOption) after(*callInfo, *csAttempt) {}
// OnFinish returns a CallOption that configures a callback to be called when // OnFinish returns a CallOption that configures a callback to be called when
// the call completes. The error passed to the callback is the status of the // the call completes. The error passed to the callback is the status of the
@ -339,7 +339,7 @@ func (o OnFinishCallOption) before(c *callInfo) error {
return nil return nil
} }
func (o OnFinishCallOption) after(c *callInfo, attempt *csAttempt) {} func (o OnFinishCallOption) after(*callInfo, *csAttempt) {}
// MaxCallRecvMsgSize returns a CallOption which sets the maximum message size // MaxCallRecvMsgSize returns a CallOption which sets the maximum message size
// in bytes the client can receive. If this is not set, gRPC uses the default // in bytes the client can receive. If this is not set, gRPC uses the default
@ -363,7 +363,7 @@ func (o MaxRecvMsgSizeCallOption) before(c *callInfo) error {
c.maxReceiveMessageSize = &o.MaxRecvMsgSize c.maxReceiveMessageSize = &o.MaxRecvMsgSize
return nil return nil
} }
func (o MaxRecvMsgSizeCallOption) after(c *callInfo, attempt *csAttempt) {} func (o MaxRecvMsgSizeCallOption) after(*callInfo, *csAttempt) {}
// MaxCallSendMsgSize returns a CallOption which sets the maximum message size // MaxCallSendMsgSize returns a CallOption which sets the maximum message size
// in bytes the client can send. If this is not set, gRPC uses the default // in bytes the client can send. If this is not set, gRPC uses the default
@ -387,7 +387,7 @@ func (o MaxSendMsgSizeCallOption) before(c *callInfo) error {
c.maxSendMessageSize = &o.MaxSendMsgSize c.maxSendMessageSize = &o.MaxSendMsgSize
return nil return nil
} }
func (o MaxSendMsgSizeCallOption) after(c *callInfo, attempt *csAttempt) {} func (o MaxSendMsgSizeCallOption) after(*callInfo, *csAttempt) {}
// PerRPCCredentials returns a CallOption that sets credentials.PerRPCCredentials // PerRPCCredentials returns a CallOption that sets credentials.PerRPCCredentials
// for a call. // for a call.
@ -410,7 +410,7 @@ func (o PerRPCCredsCallOption) before(c *callInfo) error {
c.creds = o.Creds c.creds = o.Creds
return nil return nil
} }
func (o PerRPCCredsCallOption) after(c *callInfo, attempt *csAttempt) {} func (o PerRPCCredsCallOption) after(*callInfo, *csAttempt) {}
// UseCompressor returns a CallOption which sets the compressor used when // UseCompressor returns a CallOption which sets the compressor used when
// sending the request. If WithCompressor is also set, UseCompressor has // sending the request. If WithCompressor is also set, UseCompressor has
@ -438,7 +438,7 @@ func (o CompressorCallOption) before(c *callInfo) error {
c.compressorType = o.CompressorType c.compressorType = o.CompressorType
return nil return nil
} }
func (o CompressorCallOption) after(c *callInfo, attempt *csAttempt) {} func (o CompressorCallOption) after(*callInfo, *csAttempt) {}
// CallContentSubtype returns a CallOption that will set the content-subtype // CallContentSubtype returns a CallOption that will set the content-subtype
// for a call. For example, if content-subtype is "json", the Content-Type over // for a call. For example, if content-subtype is "json", the Content-Type over
@ -475,7 +475,7 @@ func (o ContentSubtypeCallOption) before(c *callInfo) error {
c.contentSubtype = o.ContentSubtype c.contentSubtype = o.ContentSubtype
return nil return nil
} }
func (o ContentSubtypeCallOption) after(c *callInfo, attempt *csAttempt) {} func (o ContentSubtypeCallOption) after(*callInfo, *csAttempt) {}
// ForceCodec returns a CallOption that will set codec to be used for all // ForceCodec returns a CallOption that will set codec to be used for all
// request and response messages for a call. The result of calling Name() will // request and response messages for a call. The result of calling Name() will
@ -514,7 +514,7 @@ func (o ForceCodecCallOption) before(c *callInfo) error {
c.codec = newCodecV1Bridge(o.Codec) c.codec = newCodecV1Bridge(o.Codec)
return nil return nil
} }
func (o ForceCodecCallOption) after(c *callInfo, attempt *csAttempt) {} func (o ForceCodecCallOption) after(*callInfo, *csAttempt) {}
// ForceCodecV2 returns a CallOption that will set codec to be used for all // ForceCodecV2 returns a CallOption that will set codec to be used for all
// request and response messages for a call. The result of calling Name() will // request and response messages for a call. The result of calling Name() will
@ -554,7 +554,7 @@ func (o ForceCodecV2CallOption) before(c *callInfo) error {
return nil return nil
} }
func (o ForceCodecV2CallOption) after(c *callInfo, attempt *csAttempt) {} func (o ForceCodecV2CallOption) after(*callInfo, *csAttempt) {}
// CallCustomCodec behaves like ForceCodec, but accepts a grpc.Codec instead of // CallCustomCodec behaves like ForceCodec, but accepts a grpc.Codec instead of
// an encoding.Codec. // an encoding.Codec.
@ -579,7 +579,7 @@ func (o CustomCodecCallOption) before(c *callInfo) error {
c.codec = newCodecV0Bridge(o.Codec) c.codec = newCodecV0Bridge(o.Codec)
return nil return nil
} }
func (o CustomCodecCallOption) after(c *callInfo, attempt *csAttempt) {} func (o CustomCodecCallOption) after(*callInfo, *csAttempt) {}
// MaxRetryRPCBufferSize returns a CallOption that limits the amount of memory // MaxRetryRPCBufferSize returns a CallOption that limits the amount of memory
// used for buffering this RPC's requests for retry purposes. // used for buffering this RPC's requests for retry purposes.
@ -607,7 +607,7 @@ func (o MaxRetryRPCBufferSizeCallOption) before(c *callInfo) error {
c.maxRetryRPCBufferSize = o.MaxRetryRPCBufferSize c.maxRetryRPCBufferSize = o.MaxRetryRPCBufferSize
return nil return nil
} }
func (o MaxRetryRPCBufferSizeCallOption) after(c *callInfo, attempt *csAttempt) {} func (o MaxRetryRPCBufferSizeCallOption) after(*callInfo, *csAttempt) {}
// The format of the payload: compressed or not? // The format of the payload: compressed or not?
type payloadFormat uint8 type payloadFormat uint8

View File

@ -178,10 +178,9 @@ done
# Collection of revive linter analysis checks # Collection of revive linter analysis checks
REV_OUT="$(mktemp)" REV_OUT="$(mktemp)"
revive -formatter plain ./... >"${REV_OUT}" || true revive -set_exit_status=1 -exclude "reflection/test/grpc_testing_not_regenerate/" -formatter plain ./... >"${REV_OUT}" || true
# Error for anything other than unused-parameter linter check and in generated code.
# TODO: Remove `|| true` to unskip linter failures once existing issues are fixed. # TODO: Remove `|| true` to unskip linter failures once existing issues are fixed.
(noret_grep -v "unused-parameter" "${REV_OUT}" | not grep -v "\.pb\.go:") || true (not grep -v "\.pb\.go:" "${REV_OUT}") || true
echo SUCCESS echo SUCCESS

View File

@ -80,7 +80,7 @@ type greeterServer struct {
} }
// sayHello is a simple implementation of the pb.GreeterServer SayHello method. // sayHello is a simple implementation of the pb.GreeterServer SayHello method.
func (greeterServer) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { func (greeterServer) SayHello(_ context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
return &pb.HelloReply{Message: "Hello " + in.Name}, nil return &pb.HelloReply{Message: "Hello " + in.Name}, nil
} }
@ -175,12 +175,12 @@ func (s) TestEnd2End(t *testing.T) {
} }
}, },
clientRoot: cs.ClientTrust1, clientRoot: cs.ClientTrust1,
clientVerifyFunc: func(params *HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) { clientVerifyFunc: func(*HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) {
return &PostHandshakeVerificationResults{}, nil return &PostHandshakeVerificationResults{}, nil
}, },
clientVerificationType: CertVerification, clientVerificationType: CertVerification,
serverCert: []tls.Certificate{cs.ServerCert1}, serverCert: []tls.Certificate{cs.ServerCert1},
serverGetRoot: func(params *ConnectionInfo) (*RootCertificates, error) { serverGetRoot: func(*ConnectionInfo) (*RootCertificates, error) {
switch stage.read() { switch stage.read() {
case 0, 1: case 0, 1:
return &RootCertificates{TrustCerts: cs.ServerTrust1}, nil return &RootCertificates{TrustCerts: cs.ServerTrust1}, nil
@ -188,7 +188,7 @@ func (s) TestEnd2End(t *testing.T) {
return &RootCertificates{TrustCerts: cs.ServerTrust2}, nil return &RootCertificates{TrustCerts: cs.ServerTrust2}, nil
} }
}, },
serverVerifyFunc: func(params *HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) { serverVerifyFunc: func(*HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) {
return &PostHandshakeVerificationResults{}, nil return &PostHandshakeVerificationResults{}, nil
}, },
serverVerificationType: CertVerification, serverVerificationType: CertVerification,
@ -208,7 +208,7 @@ func (s) TestEnd2End(t *testing.T) {
{ {
desc: "test the reloading feature for server identity callback and client trust callback", desc: "test the reloading feature for server identity callback and client trust callback",
clientCert: []tls.Certificate{cs.ClientCert1}, clientCert: []tls.Certificate{cs.ClientCert1},
clientGetRoot: func(params *ConnectionInfo) (*RootCertificates, error) { clientGetRoot: func(*ConnectionInfo) (*RootCertificates, error) {
switch stage.read() { switch stage.read() {
case 0, 1: case 0, 1:
return &RootCertificates{TrustCerts: cs.ClientTrust1}, nil return &RootCertificates{TrustCerts: cs.ClientTrust1}, nil
@ -216,7 +216,7 @@ func (s) TestEnd2End(t *testing.T) {
return &RootCertificates{TrustCerts: cs.ClientTrust2}, nil return &RootCertificates{TrustCerts: cs.ClientTrust2}, nil
} }
}, },
clientVerifyFunc: func(params *HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) { clientVerifyFunc: func(*HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) {
return &PostHandshakeVerificationResults{}, nil return &PostHandshakeVerificationResults{}, nil
}, },
clientVerificationType: CertVerification, clientVerificationType: CertVerification,
@ -229,7 +229,7 @@ func (s) TestEnd2End(t *testing.T) {
} }
}, },
serverRoot: cs.ServerTrust1, serverRoot: cs.ServerTrust1,
serverVerifyFunc: func(params *HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) { serverVerifyFunc: func(*HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) {
return &PostHandshakeVerificationResults{}, nil return &PostHandshakeVerificationResults{}, nil
}, },
serverVerificationType: CertVerification, serverVerificationType: CertVerification,
@ -250,7 +250,7 @@ func (s) TestEnd2End(t *testing.T) {
{ {
desc: "test client custom verification", desc: "test client custom verification",
clientCert: []tls.Certificate{cs.ClientCert1}, clientCert: []tls.Certificate{cs.ClientCert1},
clientGetRoot: func(params *ConnectionInfo) (*RootCertificates, error) { clientGetRoot: func(*ConnectionInfo) (*RootCertificates, error) {
switch stage.read() { switch stage.read() {
case 0: case 0:
return &RootCertificates{TrustCerts: cs.ClientTrust1}, nil return &RootCertificates{TrustCerts: cs.ClientTrust1}, nil
@ -294,7 +294,7 @@ func (s) TestEnd2End(t *testing.T) {
} }
}, },
serverRoot: cs.ServerTrust1, serverRoot: cs.ServerTrust1,
serverVerifyFunc: func(params *HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) { serverVerifyFunc: func(*HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) {
return &PostHandshakeVerificationResults{}, nil return &PostHandshakeVerificationResults{}, nil
}, },
serverVerificationType: CertVerification, serverVerificationType: CertVerification,
@ -314,13 +314,13 @@ func (s) TestEnd2End(t *testing.T) {
desc: "TestServerCustomVerification", desc: "TestServerCustomVerification",
clientCert: []tls.Certificate{cs.ClientCert1}, clientCert: []tls.Certificate{cs.ClientCert1},
clientRoot: cs.ClientTrust1, clientRoot: cs.ClientTrust1,
clientVerifyFunc: func(params *HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) { clientVerifyFunc: func(*HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) {
return &PostHandshakeVerificationResults{}, nil return &PostHandshakeVerificationResults{}, nil
}, },
clientVerificationType: CertVerification, clientVerificationType: CertVerification,
serverCert: []tls.Certificate{cs.ServerCert1}, serverCert: []tls.Certificate{cs.ServerCert1},
serverRoot: cs.ServerTrust1, serverRoot: cs.ServerTrust1,
serverVerifyFunc: func(params *HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) { serverVerifyFunc: func(*HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) {
switch stage.read() { switch stage.read() {
case 0, 2: case 0, 2:
return &PostHandshakeVerificationResults{}, nil return &PostHandshakeVerificationResults{}, nil
@ -635,7 +635,7 @@ func (s) TestPEMFileProviderEnd2End(t *testing.T) {
RootProvider: serverRootProvider, RootProvider: serverRootProvider,
}, },
RequireClientCert: true, RequireClientCert: true,
AdditionalPeerVerification: func(params *HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) { AdditionalPeerVerification: func(*HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) {
return &PostHandshakeVerificationResults{}, nil return &PostHandshakeVerificationResults{}, nil
}, },
VerificationType: CertVerification, VerificationType: CertVerification,
@ -658,7 +658,7 @@ func (s) TestPEMFileProviderEnd2End(t *testing.T) {
IdentityOptions: IdentityCertificateOptions{ IdentityOptions: IdentityCertificateOptions{
IdentityProvider: clientIdentityProvider, IdentityProvider: clientIdentityProvider,
}, },
AdditionalPeerVerification: func(params *HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) { AdditionalPeerVerification: func(*HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) {
return &PostHandshakeVerificationResults{}, nil return &PostHandshakeVerificationResults{}, nil
}, },
RootOptions: RootCertificateOptions{ RootOptions: RootCertificateOptions{

View File

@ -59,7 +59,7 @@ type fakeProvider struct {
wantError bool wantError bool
} }
func (f fakeProvider) KeyMaterial(ctx context.Context) (*certprovider.KeyMaterial, error) { func (f fakeProvider) KeyMaterial(context.Context) (*certprovider.KeyMaterial, error) {
if f.wantError { if f.wantError {
return nil, fmt.Errorf("bad fakeProvider") return nil, fmt.Errorf("bad fakeProvider")
} }
@ -391,7 +391,7 @@ func (s) TestClientServerHandshake(t *testing.T) {
if err := cs.LoadCerts(); err != nil { if err := cs.LoadCerts(); err != nil {
t.Fatalf("cs.LoadCerts() failed, err: %v", err) t.Fatalf("cs.LoadCerts() failed, err: %v", err)
} }
getRootCertificatesForClient := func(params *ConnectionInfo) (*RootCertificates, error) { getRootCertificatesForClient := func(*ConnectionInfo) (*RootCertificates, error) {
return &RootCertificates{TrustCerts: cs.ClientTrust1}, nil return &RootCertificates{TrustCerts: cs.ClientTrust1}, nil
} }
@ -406,10 +406,10 @@ func (s) TestClientServerHandshake(t *testing.T) {
return &PostHandshakeVerificationResults{}, nil return &PostHandshakeVerificationResults{}, nil
} }
verifyFuncBad := func(params *HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) { verifyFuncBad := func(*HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) {
return nil, fmt.Errorf("custom verification function failed") return nil, fmt.Errorf("custom verification function failed")
} }
getRootCertificatesForServer := func(params *ConnectionInfo) (*RootCertificates, error) { getRootCertificatesForServer := func(*ConnectionInfo) (*RootCertificates, error) {
return &RootCertificates{TrustCerts: cs.ServerTrust1}, nil return &RootCertificates{TrustCerts: cs.ServerTrust1}, nil
} }
serverVerifyFunc := func(params *HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) { serverVerifyFunc := func(params *HandshakeVerificationInfo) (*PostHandshakeVerificationResults, error) {
@ -423,15 +423,15 @@ func (s) TestClientServerHandshake(t *testing.T) {
return &PostHandshakeVerificationResults{}, nil return &PostHandshakeVerificationResults{}, nil
} }
getRootCertificatesForServerBad := func(params *ConnectionInfo) (*RootCertificates, error) { getRootCertificatesForServerBad := func(*ConnectionInfo) (*RootCertificates, error) {
return nil, fmt.Errorf("bad root certificate reloading") return nil, fmt.Errorf("bad root certificate reloading")
} }
getRootCertificatesForClientCRL := func(params *ConnectionInfo) (*RootCertificates, error) { getRootCertificatesForClientCRL := func(*ConnectionInfo) (*RootCertificates, error) {
return &RootCertificates{TrustCerts: cs.ClientTrust3}, nil return &RootCertificates{TrustCerts: cs.ClientTrust3}, nil
} }
getRootCertificatesForServerCRL := func(params *ConnectionInfo) (*RootCertificates, error) { getRootCertificatesForServerCRL := func(*ConnectionInfo) (*RootCertificates, error) {
return &RootCertificates{TrustCerts: cs.ServerTrust3}, nil return &RootCertificates{TrustCerts: cs.ServerTrust3}, nil
} }
@ -558,14 +558,14 @@ func (s) TestClientServerHandshake(t *testing.T) {
// Expected Behavior: success // Expected Behavior: success
{ {
desc: "Client sets reload peer/root function with verifyFuncGood; Server sets reload peer/root function with verifyFuncGood; mutualTLS", desc: "Client sets reload peer/root function with verifyFuncGood; Server sets reload peer/root function with verifyFuncGood; mutualTLS",
clientGetCert: func(info *tls.CertificateRequestInfo) (*tls.Certificate, error) { clientGetCert: func(*tls.CertificateRequestInfo) (*tls.Certificate, error) {
return &cs.ClientCert1, nil return &cs.ClientCert1, nil
}, },
clientGetRoot: getRootCertificatesForClient, clientGetRoot: getRootCertificatesForClient,
clientVerifyFunc: clientVerifyFuncGood, clientVerifyFunc: clientVerifyFuncGood,
clientVerificationType: CertVerification, clientVerificationType: CertVerification,
serverMutualTLS: true, serverMutualTLS: true,
serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) { serverGetCert: func(*tls.ClientHelloInfo) ([]*tls.Certificate, error) {
return []*tls.Certificate{&cs.ServerCert1}, nil return []*tls.Certificate{&cs.ServerCert1}, nil
}, },
serverGetRoot: getRootCertificatesForServer, serverGetRoot: getRootCertificatesForServer,
@ -579,14 +579,14 @@ func (s) TestClientServerHandshake(t *testing.T) {
// certificate mismatch // certificate mismatch
{ {
desc: "Client sends wrong peer cert; Server sets reload peer/root function with verifyFuncGood; mutualTLS", desc: "Client sends wrong peer cert; Server sets reload peer/root function with verifyFuncGood; mutualTLS",
clientGetCert: func(info *tls.CertificateRequestInfo) (*tls.Certificate, error) { clientGetCert: func(*tls.CertificateRequestInfo) (*tls.Certificate, error) {
return &cs.ServerCert1, nil return &cs.ServerCert1, nil
}, },
clientGetRoot: getRootCertificatesForClient, clientGetRoot: getRootCertificatesForClient,
clientVerifyFunc: clientVerifyFuncGood, clientVerifyFunc: clientVerifyFuncGood,
clientVerificationType: CertVerification, clientVerificationType: CertVerification,
serverMutualTLS: true, serverMutualTLS: true,
serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) { serverGetCert: func(*tls.ClientHelloInfo) ([]*tls.Certificate, error) {
return []*tls.Certificate{&cs.ServerCert1}, nil return []*tls.Certificate{&cs.ServerCert1}, nil
}, },
serverGetRoot: getRootCertificatesForServer, serverGetRoot: getRootCertificatesForServer,
@ -600,7 +600,7 @@ func (s) TestClientServerHandshake(t *testing.T) {
// certificate mismatch and handshake failure // certificate mismatch and handshake failure
{ {
desc: "Client has wrong trust cert; Server sets reload peer/root function with verifyFuncGood; mutualTLS", desc: "Client has wrong trust cert; Server sets reload peer/root function with verifyFuncGood; mutualTLS",
clientGetCert: func(info *tls.CertificateRequestInfo) (*tls.Certificate, error) { clientGetCert: func(*tls.CertificateRequestInfo) (*tls.Certificate, error) {
return &cs.ClientCert1, nil return &cs.ClientCert1, nil
}, },
clientGetRoot: getRootCertificatesForServer, clientGetRoot: getRootCertificatesForServer,
@ -608,7 +608,7 @@ func (s) TestClientServerHandshake(t *testing.T) {
clientVerificationType: CertVerification, clientVerificationType: CertVerification,
clientExpectHandshakeError: true, clientExpectHandshakeError: true,
serverMutualTLS: true, serverMutualTLS: true,
serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) { serverGetCert: func(*tls.ClientHelloInfo) ([]*tls.Certificate, error) {
return []*tls.Certificate{&cs.ServerCert1}, nil return []*tls.Certificate{&cs.ServerCert1}, nil
}, },
serverGetRoot: getRootCertificatesForServer, serverGetRoot: getRootCertificatesForServer,
@ -623,14 +623,14 @@ func (s) TestClientServerHandshake(t *testing.T) {
// certificate mismatch and handshake failure // certificate mismatch and handshake failure
{ {
desc: "Client sets reload peer/root function with verifyFuncGood; Server sends wrong peer cert; mutualTLS", desc: "Client sets reload peer/root function with verifyFuncGood; Server sends wrong peer cert; mutualTLS",
clientGetCert: func(info *tls.CertificateRequestInfo) (*tls.Certificate, error) { clientGetCert: func(*tls.CertificateRequestInfo) (*tls.Certificate, error) {
return &cs.ClientCert1, nil return &cs.ClientCert1, nil
}, },
clientGetRoot: getRootCertificatesForClient, clientGetRoot: getRootCertificatesForClient,
clientVerifyFunc: clientVerifyFuncGood, clientVerifyFunc: clientVerifyFuncGood,
clientVerificationType: CertVerification, clientVerificationType: CertVerification,
serverMutualTLS: true, serverMutualTLS: true,
serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) { serverGetCert: func(*tls.ClientHelloInfo) ([]*tls.Certificate, error) {
return []*tls.Certificate{&cs.ClientCert1}, nil return []*tls.Certificate{&cs.ClientCert1}, nil
}, },
serverGetRoot: getRootCertificatesForServer, serverGetRoot: getRootCertificatesForServer,
@ -644,7 +644,7 @@ func (s) TestClientServerHandshake(t *testing.T) {
// certificate mismatch and handshake failure // certificate mismatch and handshake failure
{ {
desc: "Client sets reload peer/root function with verifyFuncGood; Server has wrong trust cert; mutualTLS", desc: "Client sets reload peer/root function with verifyFuncGood; Server has wrong trust cert; mutualTLS",
clientGetCert: func(info *tls.CertificateRequestInfo) (*tls.Certificate, error) { clientGetCert: func(*tls.CertificateRequestInfo) (*tls.Certificate, error) {
return &cs.ClientCert1, nil return &cs.ClientCert1, nil
}, },
clientGetRoot: getRootCertificatesForClient, clientGetRoot: getRootCertificatesForClient,
@ -652,7 +652,7 @@ func (s) TestClientServerHandshake(t *testing.T) {
clientVerificationType: CertVerification, clientVerificationType: CertVerification,
clientExpectHandshakeError: true, clientExpectHandshakeError: true,
serverMutualTLS: true, serverMutualTLS: true,
serverGetCert: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) { serverGetCert: func(*tls.ClientHelloInfo) ([]*tls.Certificate, error) {
return []*tls.Certificate{&cs.ServerCert1}, nil return []*tls.Certificate{&cs.ServerCert1}, nil
}, },
serverGetRoot: getRootCertificatesForClient, serverGetRoot: getRootCertificatesForClient,
@ -1040,7 +1040,7 @@ func (s) TestGetCertificatesSNI(t *testing.T) {
t.Run(test.desc, func(t *testing.T) { t.Run(test.desc, func(t *testing.T) {
serverOptions := &Options{ serverOptions := &Options{
IdentityOptions: IdentityCertificateOptions{ IdentityOptions: IdentityCertificateOptions{
GetIdentityCertificatesForServer: func(info *tls.ClientHelloInfo) ([]*tls.Certificate, error) { GetIdentityCertificatesForServer: func(*tls.ClientHelloInfo) ([]*tls.Certificate, error) {
return []*tls.Certificate{&cs.ServerCert1, &cs.ServerCert2, &cs.ServerPeer3}, nil return []*tls.Certificate{&cs.ServerCert1, &cs.ServerCert2, &cs.ServerPeer3}, nil
}, },
}, },

Some files were not shown because too many files have changed in this diff Show More