diff --git a/vici/client_conn.go b/vici/client_conn.go index 665854d..9b85536 100644 --- a/vici/client_conn.go +++ b/vici/client_conn.go @@ -116,11 +116,11 @@ func (cc *clientConn) packetRead(ctx context.Context) (*Message, error) { return nil, ctx.Err() case v := <-rc: - switch v.(type) { + switch v := v.(type) { case error: - return nil, v.(error) + return nil, v case *Message: - return v.(*Message), nil + return v, nil default: // This is a programmer error. return nil, fmt.Errorf("%v: invalid packet read", errEncoding) diff --git a/vici/message.go b/vici/message.go index 1800a96..219d07e 100644 --- a/vici/message.go +++ b/vici/message.go @@ -465,11 +465,12 @@ func (m *Message) decode(data []byte) error { return fmt.Errorf("%v: %v", errDecoding, err) } - if name := buf.Next(int(l)); len(name) != int(l) { + name := buf.Next(int(l)) + if len(name) != int(l) { return errBadName - } else { - m.header.name = string(name) } + + m.header.name = string(name) } for buf.Len() > 0 { @@ -609,7 +610,6 @@ func (m *Message) encodeSection(key string, section *Message) ([]byte, error) { // Encode the sections elements for k, v := range section.elements() { - rv := reflect.ValueOf(v) var data []byte