From 251ec813047ca79f50f8bd9c7825feddec470d39 Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Thu, 12 Aug 2021 09:56:35 -0700 Subject: [PATCH] client: clean up control flow in the Batch method --- client.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client.go b/client.go index a193fae..80a0c10 100644 --- a/client.go +++ b/client.go @@ -324,17 +324,17 @@ func (c *Client) CallResult(ctx context.Context, method string, params, result i func (c *Client) Batch(ctx context.Context, specs []Spec) ([]*Response, error) { reqs := make(jmessages, len(specs)) for i, spec := range specs { + var req *jmessage + var err error if spec.Notify { - req, err := c.note(ctx, spec.Method, spec.Params) - if err != nil { - return nil, err - } - reqs[i] = req - } else if req, err := c.req(ctx, spec.Method, spec.Params); err != nil { - return nil, err + req, err = c.note(ctx, spec.Method, spec.Params) } else { - reqs[i] = req + req, err = c.req(ctx, spec.Method, spec.Params) + } + if err != nil { + return nil, err } + reqs[i] = req } rsps, err := c.send(ctx, reqs) if err != nil {