From a3a5046ecc8925150a1cbc7943d58630ff61d9b6 Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Mon, 15 May 2023 17:25:04 +0300 Subject: [PATCH] [#28] Replace interface{} with any Signed-off-by: Anton Nikiforov --- pkg/tracing/grpc.go | 6 +++--- pkg/tracing/grpc_internal.go | 8 ++++---- rpc/grpc/init.go | 2 +- rpc/message/message.go | 4 ++-- signature/body.go | 2 +- signature/sign.go | 2 +- signature/verify.go | 2 +- status/test/codes.go | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/tracing/grpc.go b/pkg/tracing/grpc.go index 884ecb2b..f0a34733 100644 --- a/pkg/tracing/grpc.go +++ b/pkg/tracing/grpc.go @@ -15,7 +15,7 @@ import ( // NewGRPCUnaryClientInteceptor creates new gRPC unary interceptor to save gRPC client traces. func NewGRPCUnaryClientInteceptor() grpc.UnaryClientInterceptor { - return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { ctx, span := startClientSpan(ctx, cc, method) defer span.End() @@ -74,7 +74,7 @@ func NewGRPCStreamClientInterceptor() grpc.StreamClientInterceptor { // NewGRPCUnaryServerInterceptor creates new gRPC unary interceptor to save gRPC server traces. func NewGRPCUnaryServerInterceptor() grpc.UnaryServerInterceptor { - return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) { + return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) { ctx = extractGRPCTraceInfo(ctx) var span trace.Span ctx, span = StartSpanFromContext(ctx, info.FullMethod, @@ -94,7 +94,7 @@ func NewGRPCUnaryServerInterceptor() grpc.UnaryServerInterceptor { // NewGRPCStreamServerInterceptor creates new gRPC stream interceptor to save gRPC server traces. func NewGRPCStreamServerInterceptor() grpc.StreamServerInterceptor { - return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + return func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { ctx := extractGRPCTraceInfo(ss.Context()) var span trace.Span ctx, span = StartSpanFromContext(ctx, info.FullMethod, diff --git a/pkg/tracing/grpc_internal.go b/pkg/tracing/grpc_internal.go index 847c7caa..7c1bfab8 100644 --- a/pkg/tracing/grpc_internal.go +++ b/pkg/tracing/grpc_internal.go @@ -100,7 +100,7 @@ func (cs *clientStream) Context() context.Context { return cs.originalStream.Context() } -func (cs *clientStream) SendMsg(m interface{}) error { +func (cs *clientStream) SendMsg(m any) error { err := cs.originalStream.SendMsg(m) if err != nil { select { @@ -111,7 +111,7 @@ func (cs *clientStream) SendMsg(m interface{}) error { return err } -func (cs *clientStream) RecvMsg(m interface{}) error { +func (cs *clientStream) RecvMsg(m any) error { err := cs.originalStream.RecvMsg(m) if err != nil || !cs.desc.ServerStreams { select { @@ -150,10 +150,10 @@ func (ss *serverStream) Context() context.Context { return ss.ctx } -func (ss *serverStream) SendMsg(m interface{}) error { +func (ss *serverStream) SendMsg(m any) error { return ss.originalStream.SendMsg(m) } -func (ss *serverStream) RecvMsg(m interface{}) error { +func (ss *serverStream) RecvMsg(m any) error { return ss.originalStream.RecvMsg(m) } diff --git a/rpc/grpc/init.go b/rpc/grpc/init.go index 79f08c95..0092d395 100644 --- a/rpc/grpc/init.go +++ b/rpc/grpc/init.go @@ -1,4 +1,4 @@ package grpc // Message represents raw gRPC message. -type Message interface{} +type Message any diff --git a/rpc/message/message.go b/rpc/message/message.go index c9b87f0c..705270e7 100644 --- a/rpc/message/message.go +++ b/rpc/message/message.go @@ -26,12 +26,12 @@ type Message interface { // ErrUnexpectedMessageType is an error that // is used to indicate message mismatch. type ErrUnexpectedMessageType struct { - exp, act interface{} + exp, act any } // NewUnexpectedMessageType initializes an error about message mismatch // between act and exp. -func NewUnexpectedMessageType(act, exp interface{}) ErrUnexpectedMessageType { +func NewUnexpectedMessageType(act, exp any) ErrUnexpectedMessageType { return ErrUnexpectedMessageType{ exp: exp, act: act, diff --git a/signature/body.go b/signature/body.go index f5373598..6d432495 100644 --- a/signature/body.go +++ b/signature/body.go @@ -11,7 +11,7 @@ import ( ) // nolint:funlen -func serviceMessageBody(req interface{}) stableMarshaler { +func serviceMessageBody(req any) stableMarshaler { switch v := req.(type) { default: panic(fmt.Sprintf("unsupported session message %T", req)) diff --git a/signature/sign.go b/signature/sign.go index 49343bd8..f50d83fc 100644 --- a/signature/sign.go +++ b/signature/sign.go @@ -29,7 +29,7 @@ type signatureReceiver interface { } // SignServiceMessage signes service message with key. -func SignServiceMessage(key *ecdsa.PrivateKey, msg interface{}) error { +func SignServiceMessage(key *ecdsa.PrivateKey, msg any) error { switch v := msg.(type) { case nil: return nil diff --git a/signature/verify.go b/signature/verify.go index 67e4a820..7a8ed824 100644 --- a/signature/verify.go +++ b/signature/verify.go @@ -17,7 +17,7 @@ type signatureProvider interface { } // VerifyServiceMessage verifies service message. -func VerifyServiceMessage(msg interface{}) error { +func VerifyServiceMessage(msg any) error { switch v := msg.(type) { case nil: return nil diff --git a/status/test/codes.go b/status/test/codes.go index 3a2e0016..b832c871 100644 --- a/status/test/codes.go +++ b/status/test/codes.go @@ -12,7 +12,7 @@ import ( func TestCodes(t *testing.T, localizer func(*status.Code) bool, globalizer func(code *status.Code), - vals ...interface{}, + vals ...any, ) { for i := 0; i < len(vals); i += 2 { c := vals[i].(status.Code)