1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-11-24 08:02:32 +02:00

named return value for error defer modify.

This commit is contained in:
Astone 2019-12-09 11:08:21 +08:00
parent e2b2a30668
commit caa1bcf9fe
3 changed files with 3 additions and 6 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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,