From cff9804673b61c50ddd7835fa241c3923bd682ff Mon Sep 17 00:00:00 2001 From: Kevin Park Date: Sat, 2 Dec 2023 18:03:41 +0900 Subject: [PATCH] Lint codes --- admin/auth.go | 3 ++- admin/client.go | 7 ++++--- api/converter/from_bytes.go | 1 + api/converter/from_pb.go | 1 + api/converter/to_bytes.go | 3 ++- api/converter/to_pb.go | 3 ++- api/yorkie/v1/admin.pb.go | 5 +++-- api/yorkie/v1/resources.pb.go | 5 +++-- api/yorkie/v1/v1connect/admin.connect.go | 5 +++-- api/yorkie/v1/v1connect/yorkie.connect.go | 5 +++-- api/yorkie/v1/yorkie.pb.go | 5 +++-- client/auth.go | 3 ++- client/client.go | 7 ++++--- client/client_test.go | 5 +++-- server/backend/database/change_info.go | 1 + server/profiling/prometheus/metrics.go | 2 +- server/rpc/admin_server.go | 3 ++- server/rpc/connecthelper/logging.go | 5 +++-- server/rpc/connecthelper/status.go | 3 ++- server/rpc/interceptors/admin_auth.go | 3 ++- server/rpc/interceptors/context.go | 5 +++-- server/rpc/interceptors/default.go | 5 +++-- server/rpc/server.go | 7 ++++--- server/rpc/server_test.go | 21 +++++++++++++++------ server/rpc/yorkie_server.go | 3 ++- 25 files changed, 74 insertions(+), 42 deletions(-) diff --git a/admin/auth.go b/admin/auth.go index 9d7a49b46..9d4de4407 100644 --- a/admin/auth.go +++ b/admin/auth.go @@ -17,9 +17,10 @@ package admin import ( - "connectrpc.com/connect" "context" + "connectrpc.com/connect" + "github.com/yorkie-team/yorkie/api/types" "github.com/yorkie-team/yorkie/internal/version" ) diff --git a/admin/client.go b/admin/client.go index 0d422f80d..fe9e6bdfc 100644 --- a/admin/client.go +++ b/admin/client.go @@ -18,14 +18,15 @@ package admin import ( - "connectrpc.com/connect" "context" "fmt" - api "github.com/yorkie-team/yorkie/api/yorkie/v1" - "github.com/yorkie-team/yorkie/api/yorkie/v1/v1connect" "net/http" "strings" + "connectrpc.com/connect" + api "github.com/yorkie-team/yorkie/api/yorkie/v1" + "github.com/yorkie-team/yorkie/api/yorkie/v1/v1connect" + "go.uber.org/zap" "google.golang.org/grpc/metadata" diff --git a/api/converter/from_bytes.go b/api/converter/from_bytes.go index 9b505d6fd..8e3e41abd 100644 --- a/api/converter/from_bytes.go +++ b/api/converter/from_bytes.go @@ -19,6 +19,7 @@ package converter import ( "errors" "fmt" + "google.golang.org/protobuf/proto" api "github.com/yorkie-team/yorkie/api/yorkie/v1" diff --git a/api/converter/from_pb.go b/api/converter/from_pb.go index e90138d42..d1716f8e9 100644 --- a/api/converter/from_pb.go +++ b/api/converter/from_pb.go @@ -18,6 +18,7 @@ package converter import ( "fmt" + "github.com/yorkie-team/yorkie/api/types" api "github.com/yorkie-team/yorkie/api/yorkie/v1" "github.com/yorkie-team/yorkie/pkg/document/change" diff --git a/api/converter/to_bytes.go b/api/converter/to_bytes.go index 345c83779..7913279d1 100644 --- a/api/converter/to_bytes.go +++ b/api/converter/to_bytes.go @@ -18,9 +18,10 @@ package converter import ( "fmt" - "google.golang.org/protobuf/proto" "reflect" + "google.golang.org/protobuf/proto" + api "github.com/yorkie-team/yorkie/api/yorkie/v1" "github.com/yorkie-team/yorkie/pkg/document/crdt" "github.com/yorkie-team/yorkie/pkg/document/innerpresence" diff --git a/api/converter/to_pb.go b/api/converter/to_pb.go index f30c31b30..c8da5e106 100644 --- a/api/converter/to_pb.go +++ b/api/converter/to_pb.go @@ -18,9 +18,10 @@ package converter import ( "fmt" + "reflect" + "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" - "reflect" "github.com/yorkie-team/yorkie/api/types" api "github.com/yorkie-team/yorkie/api/yorkie/v1" diff --git a/api/yorkie/v1/admin.pb.go b/api/yorkie/v1/admin.pb.go index 7ff402031..1c0f261ef 100644 --- a/api/yorkie/v1/admin.pb.go +++ b/api/yorkie/v1/admin.pb.go @@ -22,10 +22,11 @@ package v1 import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/api/yorkie/v1/resources.pb.go b/api/yorkie/v1/resources.pb.go index 66671cb14..19a52a39a 100644 --- a/api/yorkie/v1/resources.pb.go +++ b/api/yorkie/v1/resources.pb.go @@ -22,12 +22,13 @@ package v1 import ( + reflect "reflect" + sync "sync" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" timestamppb "google.golang.org/protobuf/types/known/timestamppb" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" - reflect "reflect" - sync "sync" ) const ( diff --git a/api/yorkie/v1/v1connect/admin.connect.go b/api/yorkie/v1/v1connect/admin.connect.go index d78294f72..8faa6a819 100644 --- a/api/yorkie/v1/v1connect/admin.connect.go +++ b/api/yorkie/v1/v1connect/admin.connect.go @@ -20,12 +20,13 @@ package v1connect import ( - connect "connectrpc.com/connect" context "context" errors "errors" - v1 "github.com/yorkie-team/yorkie/api/yorkie/v1" http "net/http" strings "strings" + + connect "connectrpc.com/connect" + v1 "github.com/yorkie-team/yorkie/api/yorkie/v1" ) // This is a compile-time assertion to ensure that this generated file and the connect package are diff --git a/api/yorkie/v1/v1connect/yorkie.connect.go b/api/yorkie/v1/v1connect/yorkie.connect.go index 79f4d2636..e913c4f3b 100644 --- a/api/yorkie/v1/v1connect/yorkie.connect.go +++ b/api/yorkie/v1/v1connect/yorkie.connect.go @@ -20,12 +20,13 @@ package v1connect import ( - connect "connectrpc.com/connect" context "context" errors "errors" - v1 "github.com/yorkie-team/yorkie/api/yorkie/v1" http "net/http" strings "strings" + + connect "connectrpc.com/connect" + v1 "github.com/yorkie-team/yorkie/api/yorkie/v1" ) // This is a compile-time assertion to ensure that this generated file and the connect package are diff --git a/api/yorkie/v1/yorkie.pb.go b/api/yorkie/v1/yorkie.pb.go index 0a49dba9f..4614d6595 100644 --- a/api/yorkie/v1/yorkie.pb.go +++ b/api/yorkie/v1/yorkie.pb.go @@ -22,10 +22,11 @@ package v1 import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/client/auth.go b/client/auth.go index 7712c4e0f..0d62ad240 100644 --- a/client/auth.go +++ b/client/auth.go @@ -17,9 +17,10 @@ package client import ( - "connectrpc.com/connect" "context" + "connectrpc.com/connect" + "github.com/yorkie-team/yorkie/api/types" "github.com/yorkie-team/yorkie/internal/version" ) diff --git a/client/client.go b/client/client.go index 2a911be0f..8c46a35e1 100644 --- a/client/client.go +++ b/client/client.go @@ -19,15 +19,16 @@ package client import ( - "connectrpc.com/connect" "context" "errors" "fmt" + "net/http" + "strings" + + "connectrpc.com/connect" "github.com/rs/xid" "github.com/yorkie-team/yorkie/api/yorkie/v1/v1connect" "go.uber.org/zap" - "net/http" - "strings" //"google.golang.org/grpc" //"google.golang.org/grpc/credentials" diff --git a/client/client_test.go b/client/client_test.go index f26071aac..fa062334c 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -19,14 +19,15 @@ package client_test import ( - "connectrpc.com/connect" "context" - "github.com/yorkie-team/yorkie/api/yorkie/v1/v1connect" "net/http" "net/http/httptest" "reflect" "testing" + "connectrpc.com/connect" + "github.com/yorkie-team/yorkie/api/yorkie/v1/v1connect" + "github.com/rs/xid" "github.com/stretchr/testify/assert" monkey "github.com/undefinedlabs/go-mpatch" diff --git a/server/backend/database/change_info.go b/server/backend/database/change_info.go index 238243cae..52526cd1c 100644 --- a/server/backend/database/change_info.go +++ b/server/backend/database/change_info.go @@ -20,6 +20,7 @@ import ( "encoding/json" "errors" "fmt" + "google.golang.org/protobuf/proto" "github.com/yorkie-team/yorkie/api/converter" diff --git a/server/profiling/prometheus/metrics.go b/server/profiling/prometheus/metrics.go index 798ca4351..dafdea31d 100644 --- a/server/profiling/prometheus/metrics.go +++ b/server/profiling/prometheus/metrics.go @@ -52,7 +52,7 @@ var ( type Metrics struct { registry *prometheus.Registry serverMetrics *grpcprometheus.ServerMetrics - + serverVersion *prometheus.GaugeVec pushPullResponseSeconds prometheus.Histogram diff --git a/server/rpc/admin_server.go b/server/rpc/admin_server.go index 738aa8372..98f9a7bd7 100644 --- a/server/rpc/admin_server.go +++ b/server/rpc/admin_server.go @@ -17,10 +17,11 @@ package rpc import ( - "connectrpc.com/connect" "context" "fmt" + "connectrpc.com/connect" + "github.com/yorkie-team/yorkie/api/converter" "github.com/yorkie-team/yorkie/api/types" api "github.com/yorkie-team/yorkie/api/yorkie/v1" diff --git a/server/rpc/connecthelper/logging.go b/server/rpc/connecthelper/logging.go index ccf87faf9..742b6c224 100644 --- a/server/rpc/connecthelper/logging.go +++ b/server/rpc/connecthelper/logging.go @@ -18,11 +18,12 @@ package connecthelper import ( - "connectrpc.com/connect" "context" - "github.com/yorkie-team/yorkie/server/logging" "strconv" "sync/atomic" + + "connectrpc.com/connect" + "github.com/yorkie-team/yorkie/server/logging" ) type reqID int32 diff --git a/server/rpc/connecthelper/status.go b/server/rpc/connecthelper/status.go index 0b2fd2410..d9fcec650 100644 --- a/server/rpc/connecthelper/status.go +++ b/server/rpc/connecthelper/status.go @@ -17,9 +17,10 @@ package connecthelper import ( - "connectrpc.com/connect" "errors" "fmt" + + "connectrpc.com/connect" "google.golang.org/genproto/googleapis/rpc/errdetails" "google.golang.org/protobuf/runtime/protoiface" diff --git a/server/rpc/interceptors/admin_auth.go b/server/rpc/interceptors/admin_auth.go index df05abdb4..4c1dcb6a6 100644 --- a/server/rpc/interceptors/admin_auth.go +++ b/server/rpc/interceptors/admin_auth.go @@ -17,11 +17,12 @@ package interceptors import ( - "connectrpc.com/connect" "context" "net/http" "strings" + "connectrpc.com/connect" + "google.golang.org/grpc/codes" grpcstatus "google.golang.org/grpc/status" diff --git a/server/rpc/interceptors/context.go b/server/rpc/interceptors/context.go index 4aa74a029..48ce64083 100644 --- a/server/rpc/interceptors/context.go +++ b/server/rpc/interceptors/context.go @@ -18,13 +18,14 @@ package interceptors import ( - "connectrpc.com/connect" "context" "errors" - "github.com/yorkie-team/yorkie/server/rpc/connecthelper" "net/http" "strings" + "connectrpc.com/connect" + "github.com/yorkie-team/yorkie/server/rpc/connecthelper" + "github.com/yorkie-team/yorkie/api/types" "github.com/yorkie-team/yorkie/pkg/cache" "github.com/yorkie-team/yorkie/server/backend" diff --git a/server/rpc/interceptors/default.go b/server/rpc/interceptors/default.go index 5333b05dd..036d49efe 100644 --- a/server/rpc/interceptors/default.go +++ b/server/rpc/interceptors/default.go @@ -17,12 +17,13 @@ package interceptors import ( - "connectrpc.com/connect" "context" "errors" - "github.com/yorkie-team/yorkie/server/rpc/connecthelper" gotime "time" + "connectrpc.com/connect" + "github.com/yorkie-team/yorkie/server/rpc/connecthelper" + "github.com/yorkie-team/yorkie/server/logging" ) diff --git a/server/rpc/server.go b/server/rpc/server.go index 7acbd2dc0..462c68a13 100644 --- a/server/rpc/server.go +++ b/server/rpc/server.go @@ -19,9 +19,12 @@ package rpc import ( - "connectrpc.com/connect" "context" "fmt" + "net/http" + "time" + + "connectrpc.com/connect" "github.com/rs/cors" "github.com/yorkie-team/yorkie/api/yorkie/v1/v1connect" "github.com/yorkie-team/yorkie/server/backend" @@ -31,8 +34,6 @@ import ( "github.com/yorkie-team/yorkie/server/rpc/interceptors" "golang.org/x/net/http2" "golang.org/x/net/http2/h2c" - "net/http" - "time" ) // Server is a normal server that processes the logic requested by the client. diff --git a/server/rpc/server_test.go b/server/rpc/server_test.go index 16ad312a4..87b6a37cc 100644 --- a/server/rpc/server_test.go +++ b/server/rpc/server_test.go @@ -17,18 +17,19 @@ package rpc_test import ( - "connectrpc.com/connect" "context" "encoding/hex" "fmt" - "github.com/stretchr/testify/assert" - "github.com/yorkie-team/yorkie/api/yorkie/v1/v1connect" - "google.golang.org/protobuf/types/known/wrapperspb" "log" "net/http" "os" "testing" + "connectrpc.com/connect" + "github.com/stretchr/testify/assert" + "github.com/yorkie-team/yorkie/api/yorkie/v1/v1connect" + "google.golang.org/protobuf/types/known/wrapperspb" + "github.com/yorkie-team/yorkie/admin" api "github.com/yorkie-team/yorkie/api/yorkie/v1" "github.com/yorkie-team/yorkie/client" @@ -120,7 +121,11 @@ func TestMain(m *testing.M) { //dialOptions = append(dialOptions, grpc.WithTransportCredentials(insecure.NewCredentials())) conn := http.DefaultClient - testClient = v1connect.NewYorkieServiceClient(conn, "http://"+testRPCAddr, connect.WithInterceptors(authInterceptor)) + testClient = v1connect.NewYorkieServiceClient( + conn, + "http://"+testRPCAddr, + connect.WithInterceptors(authInterceptor), + ) //credentials := grpc.WithTransportCredentials(insecure.NewCredentials()) //dialOptions = []grpc.DialOption{credentials} @@ -130,7 +135,11 @@ func TestMain(m *testing.M) { //dialOptions = append(dialOptions, grpc.WithStreamInterceptor(testAdminAuthInterceptor.Stream())) adminConn := http.DefaultClient - testAdminClient = v1connect.NewAdminServiceClient(adminConn, "http://"+testRPCAddr, connect.WithInterceptors(testAdminAuthInterceptor)) + testAdminClient = v1connect.NewAdminServiceClient( + adminConn, + "http://"+testRPCAddr, + connect.WithInterceptors(testAdminAuthInterceptor), + ) code := m.Run() diff --git a/server/rpc/yorkie_server.go b/server/rpc/yorkie_server.go index b0aecfc42..afee90b18 100644 --- a/server/rpc/yorkie_server.go +++ b/server/rpc/yorkie_server.go @@ -17,9 +17,10 @@ package rpc import ( - "connectrpc.com/connect" "context" "fmt" + + "connectrpc.com/connect" "github.com/yorkie-team/yorkie/api/converter" "github.com/yorkie-team/yorkie/api/types" api "github.com/yorkie-team/yorkie/api/yorkie/v1"