Fix go vet
This commit is contained in:
Родитель
f38b9a9906
Коммит
a6bacfe42c
|
@ -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()
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче