fix: fix the latest version of lint problem (#1825)

pull/1826/head
haiyux 3 years ago committed by GitHub
parent cde962a6c1
commit 370a1585a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cmd/kratos/internal/proto/client/client.go
  2. 1
      cmd/kratos/internal/upgrade/upgrade.go
  3. 6
      transport/grpc/client_test.go
  4. 7
      transport/grpc/server_test.go

@ -39,7 +39,7 @@ func run(cmd *cobra.Command, args []string) {
err error err error
proto = strings.TrimSpace(args[0]) proto = strings.TrimSpace(args[0])
) )
if err = look("protoc-gen-go", "protoc-gen-go-grpc", "protoc-gen-go-http", "protoc-gen-go-errors", "protoc-gen-validate", "protoc-gen-openapi"); err != nil { if err = look("protoc-gen-go", "protoc-gen-go-grpc", "protoc-gen-go-http", "protoc-gen-go-errors", "protoc-gen-openapi"); err != nil {
// update the kratos plugins // update the kratos plugins
cmd := exec.Command("kratos", "upgrade") cmd := exec.Command("kratos", "upgrade")
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout

@ -24,7 +24,6 @@ func Run(cmd *cobra.Command, args []string) {
"github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2@latest", "github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2@latest",
"google.golang.org/protobuf/cmd/protoc-gen-go@latest", "google.golang.org/protobuf/cmd/protoc-gen-go@latest",
"google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest", "google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest",
"github.com/envoyproxy/protoc-gen-validate@latest",
"github.com/google/gnostic/cmd/protoc-gen-openapi@latest", "github.com/google/gnostic/cmd/protoc-gen-openapi@latest",
) )
if err != nil { if err != nil {

@ -104,12 +104,10 @@ func TestUnaryClientInterceptor(t *testing.T) {
func TestWithUnaryInterceptor(t *testing.T) { func TestWithUnaryInterceptor(t *testing.T) {
o := &clientOptions{} o := &clientOptions{}
v := []grpc.UnaryClientInterceptor{ v := []grpc.UnaryClientInterceptor{
func(ctx context.Context, method string, req, reply interface{}, func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
return nil return nil
}, },
func(ctx context.Context, method string, req, reply interface{}, func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
return nil return nil
}, },
} }

@ -53,8 +53,7 @@ func TestServer(t *testing.T) {
return handler(ctx, req) return handler(ctx, req)
} }
}), }),
UnaryInterceptor(func(ctx context.Context, req interface{}, UnaryInterceptor(func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
return handler(ctx, req) return handler(ctx, req)
}), }),
Options(grpc.InitialConnWindowSize(0)), Options(grpc.InitialConnWindowSize(0)),
@ -85,8 +84,8 @@ func testClient(t *testing.T, srv *Server) {
conn, err := DialInsecure(context.Background(), conn, err := DialInsecure(context.Background(),
WithEndpoint(u.Host), WithEndpoint(u.Host),
WithOptions(grpc.WithBlock()), WithOptions(grpc.WithBlock()),
WithUnaryInterceptor(func(ctx context.Context, method string, req, reply interface{}, WithUnaryInterceptor(
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
return invoker(ctx, method, req, reply, cc, opts...) return invoker(ctx, method, req, reply, cc, opts...)
}), }),
WithMiddleware(func(handler middleware.Handler) middleware.Handler { WithMiddleware(func(handler middleware.Handler) middleware.Handler {

Loading…
Cancel
Save