diff --git a/go/grpc.go b/go/grpc.go index 07d374b10..e7dabd3c6 100644 --- a/go/grpc.go +++ b/go/grpc.go @@ -1,7 +1,7 @@ package flatbuffers -// FlatbuffersCodec implements gRPC-go Codec which is used to encode and decode messages. -var Codec string = "flatbuffers" +// Codec implements gRPC-go Codec which is used to encode and decode messages. +var Codec = "flatbuffers" type FlatbuffersCodec struct{} diff --git a/grpc/src/compiler/go_generator.cc b/grpc/src/compiler/go_generator.cc index a35e5724a..79c750fda 100644 --- a/grpc/src/compiler/go_generator.cc +++ b/grpc/src/compiler/go_generator.cc @@ -48,7 +48,7 @@ namespace grpc_go_generator { // Returns string with first letter to lowerCase grpc::string unexportName(grpc::string s) { - if (s.size() <= 0) + if (s.empty()) return s; s[0] = std::tolower(s[0]); return s; @@ -56,7 +56,7 @@ grpc::string unexportName(grpc::string s) { // Returns string with first letter to uppercase grpc::string exportName(grpc::string s) { - if (s.size() <= 0) + if (s.empty()) return s; s[0] = std::toupper(s[0]); return s; @@ -434,4 +434,4 @@ grpc::string GenerateServiceSource(grpc_generator::File *file, GenerateService(service, printer, vars); return out; } -}// Namespace grpc_go_generator \ No newline at end of file +}// Namespace grpc_go_generator diff --git a/grpc/tests/go_test.go b/grpc/tests/go_test.go index f133692cb..7192f9720 100644 --- a/grpc/tests/go_test.go +++ b/grpc/tests/go_test.go @@ -6,7 +6,6 @@ import ( "net" "testing" - "github.com/google/flatbuffers/go" "golang.org/x/net/context" "google.golang.org/grpc" ) @@ -14,8 +13,8 @@ import ( type server struct{} // test used to send and receive in grpc methods -var test string = "Flatbuffers" -var addr string = "0.0.0.0:50051" +var test = "Flatbuffers" +var addr = "0.0.0.0:50051" // gRPC server store method func (s *server) Store(context context.Context, in *Example.Monster) (*flatbuffers.Builder, error) { @@ -46,7 +45,7 @@ func StoreClient(c Example.MonsterStorageClient, t *testing.T) { b.Finish(Example.MonsterEnd(b)) out, err := c.Store(context.Background(), b) if err != nil { - t.Fatal("Store client failed: %v", err) + t.Fatalf("Store client failed: %v", err) } if string(out.Id()) != test { t.Errorf("StoreClient failed: expected=%s, got=%s\n", test, out.Id()) @@ -62,7 +61,7 @@ func RetrieveClient(c Example.MonsterStorageClient, t *testing.T) { b.Finish(Example.StatEnd(b)) out, err := c.Retrieve(context.Background(), b) if err != nil { - t.Fatal("Retrieve client failed: %v", err) + t.Fatalf("Retrieve client failed: %v", err) } if string(out.Name()) != test { t.Errorf("RetrieveClient failed: expected=%s, got=%s\n", test, out.Name()) @@ -85,7 +84,7 @@ func TestGRPC(t *testing.T) { }() conn, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithCodec(flatbuffers.FlatbuffersCodec{})) if err != nil { - t.Fatal("Failed to connect: %v", err) + t.Fatalf("Failed to connect: %v", err) } defer conn.Close() client := Example.NewMonsterStorageClient(conn)