From caa1bcf9fef1b87a35a33b68e12ebb15214fb519 Mon Sep 17 00:00:00 2001 From: Astone Date: Mon, 9 Dec 2019 11:08:21 +0800 Subject: [PATCH] named return value for error defer modify. --- server/grpc/subscriber.go | 3 +-- server/rpc_router.go | 3 +-- transport/grpc/handler.go | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/server/grpc/subscriber.go b/server/grpc/subscriber.go index 6d987974..9dd071c1 100644 --- a/server/grpc/subscriber.go +++ b/server/grpc/subscriber.go @@ -167,8 +167,7 @@ func validateSubscriber(sub server.Subscriber) error { } func (g *grpcServer) createSubHandler(sb *subscriber, opts server.Options) broker.Handler { - return func(p broker.Event) error { - var err error + return func(p broker.Event) (err error) { defer func() { if r := recover(); r != nil { diff --git a/server/rpc_router.go b/server/rpc_router.go index 19f672f4..d607f5f8 100644 --- a/server/rpc_router.go +++ b/server/rpc_router.go @@ -506,8 +506,7 @@ func (router *router) Subscribe(s Subscriber) error { return nil } -func (router *router) ProcessMessage(ctx context.Context, msg Message) error { - var err error +func (router *router) ProcessMessage(ctx context.Context, msg Message) (err error) { defer func() { // recover any panics diff --git a/transport/grpc/handler.go b/transport/grpc/handler.go index e02e1445..ce58a227 100644 --- a/transport/grpc/handler.go +++ b/transport/grpc/handler.go @@ -16,8 +16,7 @@ type microTransport struct { fn func(transport.Socket) } -func (m *microTransport) Stream(ts pb.Transport_StreamServer) error { - var err error +func (m *microTransport) Stream(ts pb.Transport_StreamServer) (err error) { sock := &grpcTransportSocket{ stream: ts,