diff --git a/balancer.go b/balancer.go index c298ae91..36204995 100644 --- a/balancer.go +++ b/balancer.go @@ -158,7 +158,7 @@ type roundRobin struct { func (rr *roundRobin) watchAddrUpdates() error { updates, err := rr.w.Next() if err != nil { - grpclog.Println("grpc: the naming watcher stops working due to %v.", err) + grpclog.Printf("grpc: the naming watcher stops working due to %v.\n", err) return err } rr.mu.Lock() diff --git a/benchmark/worker/main.go b/benchmark/worker/main.go index c8815b0e..17c52519 100644 --- a/benchmark/worker/main.go +++ b/benchmark/worker/main.go @@ -60,7 +60,7 @@ type byteBufCodec struct { func (byteBufCodec) Marshal(v interface{}) ([]byte, error) { b, ok := v.(*[]byte) if !ok { - return nil, fmt.Errorf("failed to marshal: %v is not type of *[]byte") + return nil, fmt.Errorf("failed to marshal: %v is not type of *[]byte", v) } return *b, nil } @@ -68,7 +68,7 @@ func (byteBufCodec) Marshal(v interface{}) ([]byte, error) { func (byteBufCodec) Unmarshal(data []byte, v interface{}) error { b, ok := v.(*[]byte) if !ok { - return fmt.Errorf("failed to marshal: %v is not type of *[]byte") + return fmt.Errorf("failed to marshal: %v is not type of *[]byte", v) } *b = data return nil @@ -138,8 +138,6 @@ func (s *workerServer) RunServer(stream testpb.WorkerService_RunServerServer) er return err } } - - return nil } func (s *workerServer) RunClient(stream testpb.WorkerService_RunClientServer) error { @@ -191,13 +189,11 @@ func (s *workerServer) RunClient(stream testpb.WorkerService_RunClientServer) er return err } } - - return nil } func (s *workerServer) CoreCount(ctx context.Context, in *testpb.CoreRequest) (*testpb.CoreResponse, error) { grpclog.Printf("core count: %v", runtime.NumCPU()) - return &testpb.CoreResponse{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) { diff --git a/examples/route_guide/client/client.go b/examples/route_guide/client/client.go index f84352c8..02c04909 100644 --- a/examples/route_guide/client/client.go +++ b/examples/route_guide/client/client.go @@ -115,12 +115,12 @@ func runRecordRoute(client pb.RouteGuideClient) { // runRouteChat receives a sequence of route notes, while sending notes for various locations. func runRouteChat(client pb.RouteGuideClient) { notes := []*pb.RouteNote{ - {&pb.Point{0, 1}, "First message"}, - {&pb.Point{0, 2}, "Second message"}, - {&pb.Point{0, 3}, "Third message"}, - {&pb.Point{0, 1}, "Fourth message"}, - {&pb.Point{0, 2}, "Fifth message"}, - {&pb.Point{0, 3}, "Sixth message"}, + {&pb.Point{Latitude: 0, Longitude: 1}, "First message"}, + {&pb.Point{Latitude: 0, Longitude: 2}, "Second message"}, + {&pb.Point{Latitude: 0, Longitude: 3}, "Third message"}, + {&pb.Point{Latitude: 0, Longitude: 1}, "Fourth message"}, + {&pb.Point{Latitude: 0, Longitude: 2}, "Fifth message"}, + {&pb.Point{Latitude: 0, Longitude: 3}, "Sixth message"}, } stream, err := client.RouteChat(context.Background()) if err != nil { @@ -192,7 +192,7 @@ func main() { printFeature(client, &pb.Point{0, 0}) // Looking for features between 40, -75 and 42, -73. - printFeatures(client, &pb.Rectangle{&pb.Point{400000000, -750000000}, &pb.Point{420000000, -730000000}}) + printFeatures(client, &pb.Rectangle{&pb.Point{Latitude: 400000000, Longitude: -750000000}, &pb.Point{Latitude: 420000000, Longitude: -730000000}}) // RecordRoute runRecordRoute(client) diff --git a/reflection/serverreflection.go b/reflection/serverreflection.go index efc6bc88..b044a3a8 100644 --- a/reflection/serverreflection.go +++ b/reflection/serverreflection.go @@ -253,7 +253,7 @@ func (s *serverReflectionServer) fileDescEncodingContainingSymbol(name string) ( // Metadata not valid. enc, ok := meta.([]byte) if !ok { - return nil, fmt.Errorf("invalid file descriptor for symbol: %v") + return nil, fmt.Errorf("invalid file descriptor for symbol: %v", name) } fd, err = s.decodeFileDesc(enc) diff --git a/stress/client/main.go b/stress/client/main.go index bb665e98..4579aab4 100644 --- a/stress/client/main.go +++ b/stress/client/main.go @@ -162,7 +162,7 @@ func (s *server) GetAllGauges(in *metricspb.EmptyMessage, stream metricspb.Metri defer s.mutex.RUnlock() for name, gauge := range s.gauges { - if err := stream.Send(&metricspb.GaugeResponse{Name: name, Value: &metricspb.GaugeResponse_LongValue{gauge.get()}}); err != nil { + if err := stream.Send(&metricspb.GaugeResponse{Name: name, Value: &metricspb.GaugeResponse_LongValue{LongValue: gauge.get()}}); err != nil { return err } } @@ -175,7 +175,7 @@ func (s *server) GetGauge(ctx context.Context, in *metricspb.GaugeRequest) (*met defer s.mutex.RUnlock() if g, ok := s.gauges[in.Name]; ok { - return &metricspb.GaugeResponse{Name: in.Name, Value: &metricspb.GaugeResponse_LongValue{g.get()}}, nil + return &metricspb.GaugeResponse{Name: in.Name, Value: &metricspb.GaugeResponse_LongValue{LongValue: g.get()}}, nil } return nil, grpc.Errorf(codes.InvalidArgument, "gauge with name %s not found", in.Name) } diff --git a/test/end2end_test.go b/test/end2end_test.go index b539584b..cb71db9c 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -1887,7 +1887,7 @@ func testClientRequestBodyError_Cancel_StreamingInput(t *testing.T, e env) { t.Fatal("timeout waiting for error") } if se, ok := got.(transport.StreamError); !ok || se.Code != codes.Canceled { - t.Errorf("error = %#v; want transport.StreamError with code Canceled") + t.Errorf("error = %#v; want transport.StreamError with code Canceled", got) } }) } diff --git a/transport/handler_server.go b/transport/handler_server.go index 00d3855f..4b0d5252 100644 --- a/transport/handler_server.go +++ b/transport/handler_server.go @@ -312,7 +312,7 @@ func (ht *serverHandlerTransport) HandleStreams(startStream func(*Stream)) { Addr: ht.RemoteAddr(), } if req.TLS != nil { - pr.AuthInfo = credentials.TLSInfo{*req.TLS} + pr.AuthInfo = credentials.TLSInfo{State: *req.TLS} } ctx = metadata.NewContext(ctx, ht.headerMD) ctx = peer.NewContext(ctx, pr) diff --git a/transport/http2_client.go b/transport/http2_client.go index 227686d4..f66435fd 100644 --- a/transport/http2_client.go +++ b/transport/http2_client.go @@ -175,7 +175,10 @@ func newHTTP2Client(addr string, opts *ConnectOptions) (_ ClientTransport, err e return nil, ConnectionErrorf("transport: preface mismatch, wrote %d bytes; want %d", n, len(clientPreface)) } if initialWindowSize != defaultWindowSize { - err = t.framer.writeSettings(true, http2.Setting{http2.SettingInitialWindowSize, uint32(initialWindowSize)}) + err = t.framer.writeSettings(true, http2.Setting{ + ID: http2.SettingInitialWindowSize, + Val: uint32(initialWindowSize), + }) } else { err = t.framer.writeSettings(true) } diff --git a/transport/http2_server.go b/transport/http2_server.go index 1c4d5852..cee15429 100644 --- a/transport/http2_server.go +++ b/transport/http2_server.go @@ -100,10 +100,15 @@ func newHTTP2Server(conn net.Conn, maxStreams uint32, authInfo credentials.AuthI if maxStreams == 0 { maxStreams = math.MaxUint32 } else { - settings = append(settings, http2.Setting{http2.SettingMaxConcurrentStreams, maxStreams}) + settings = append(settings, http2.Setting{ + ID: http2.SettingMaxConcurrentStreams, + Val: maxStreams, + }) } if initialWindowSize != defaultWindowSize { - settings = append(settings, http2.Setting{http2.SettingInitialWindowSize, uint32(initialWindowSize)}) + settings = append(settings, http2.Setting{ + ID: http2.SettingInitialWindowSize, + Val: uint32(initialWindowSize)}) } if err := framer.writeSettings(true, settings...); err != nil { return nil, ConnectionErrorf("transport: %v", err) diff --git a/transport/transport_test.go b/transport/transport_test.go index 6ebec452..ce015da2 100644 --- a/transport/transport_test.go +++ b/transport/transport_test.go @@ -370,7 +370,7 @@ func TestGracefulClose(t *testing.T) { go func() { defer wg.Done() if _, err := ct.NewStream(context.Background(), callHdr); err != ErrConnClosing { - t.Errorf("%v.NewStream(_, _) = _, %v, want _, %v", err, ErrConnClosing) + t.Errorf("%v.NewStream(_, _) = _, %v, want _, %v", ct, err, ErrConnClosing) } }() }