From 64b882c3c9901f25edc0684ce2a1f9b63443416b Mon Sep 17 00:00:00 2001 From: Steve Coffman Date: Thu, 26 May 2022 13:34:24 -0400 Subject: [PATCH] if else chain to switch Signed-off-by: Steve Coffman --- client/websocket.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/client/websocket.go b/client/websocket.go index 8f283072ecc..f47f8a77330 100644 --- a/client/websocket.go +++ b/client/websocket.go @@ -50,7 +50,11 @@ func (p *Client) WebsocketOnce(query string, resp interface{}, options ...Option return sock.Next(&resp) } -func (p *Client) WebsocketWithPayload(query string, initPayload map[string]interface{}, options ...Option) *Subscription { +func (p *Client) WebsocketWithPayload( + query string, + initPayload map[string]interface{}, + options ...Option, +) *Subscription { r, err := p.newRequest(query, options...) if err != nil { return errorSubscription(fmt.Errorf("request: %w", err)) @@ -116,11 +120,12 @@ func (p *Client) WebsocketWithPayload(query string, initPayload map[string]inter return err } if op.Type != dataMsg { - if op.Type == connectionKaMsg { + switch op.Type { + case connectionKaMsg: continue - } else if op.Type == errorMsg { + case errorMsg: return fmt.Errorf(string(op.Payload)) - } else { + default: return fmt.Errorf("expected data message, got %#v", op) } }