Fix problems that golang inspection reported (#1158)

This commit is contained in:
gadotroee
2022-06-23 16:49:56 +03:00
committed by GitHub
parent 8c187179b0
commit a96072623f
37 changed files with 233 additions and 791 deletions

View File

@@ -12,7 +12,7 @@ import (
"github.com/up9inc/mizu/tap/api"
)
var protocol api.Protocol = api.Protocol{
var protocol = api.Protocol{
Name: "amqp",
LongName: "Advanced Message Queuing Protocol 0-9-1",
Abbreviation: "AMQP",
@@ -74,13 +74,13 @@ func (d dissecting) Dissect(b *bufio.Reader, reader api.TcpReader, options *api.
var lastMethodFrameMessage Message
for {
frame, err := r.ReadFrame()
frameVal, err := r.readFrame()
if err == io.EOF {
// We must read until we see an EOF... very important!
return err
}
switch f := frame.(type) {
switch f := frameVal.(type) {
case *HeartbeatFrame:
// drop
@@ -203,7 +203,7 @@ func (d dissecting) Dissect(b *bufio.Reader, reader api.TcpReader, options *api.
}
default:
// log.Printf("unexpected frame: %+v", f)
// log.Printf("unexpected frameVal: %+v", f)
}
}
}

View File

@@ -43,14 +43,14 @@ In realistic implementations where performance is a concern, we would use
“gathering reads” to avoid doing three separate system calls to read a frame.
*/
func (r *AmqpReader) ReadFrame() (frame frame, err error) {
func (r *AmqpReader) readFrame() (frame frame, err error) {
var scratch [7]byte
if _, err = io.ReadFull(r.R, scratch[:7]); err != nil {
return
}
typ := uint8(scratch[0])
typ := scratch[0]
channel := binary.BigEndian.Uint16(scratch[1:3])
size := binary.BigEndian.Uint32(scratch[3:7])
@@ -94,20 +94,20 @@ func (r *AmqpReader) ReadFrame() (frame frame, err error) {
return
}
func readShortstr(r io.Reader) (v string, err error) {
func readShortStr(r io.Reader) (v string, err error) {
var length uint8
if err = binary.Read(r, binary.BigEndian, &length); err != nil {
return
}
bytes := make([]byte, length)
if _, err = io.ReadFull(r, bytes); err != nil {
bytesValue := make([]byte, length)
if _, err = io.ReadFull(r, bytesValue); err != nil {
return
}
return string(bytes), nil
return string(bytesValue), nil
}
func readLongstr(r io.Reader) (v string, err error) {
func readLongStr(r io.Reader) (v string, err error) {
var length uint32
if err = binary.Read(r, binary.BigEndian, &length); err != nil {
return
@@ -118,11 +118,11 @@ func readLongstr(r io.Reader) (v string, err error) {
return
}
bytes := make([]byte, length)
if _, err = io.ReadFull(r, bytes); err != nil {
bytesValue := make([]byte, length)
if _, err = io.ReadFull(r, bytesValue); err != nil {
return
}
return string(bytes), nil
return string(bytesValue), nil
}
func readDecimal(r io.Reader) (v Decimal, err error) {
@@ -171,7 +171,7 @@ func readField(r io.Reader) (v interface{}, err error) {
if err = binary.Read(r, binary.BigEndian, &value); err != nil {
return
}
return (value != 0), nil
return value != 0, nil
case 'b':
var value [1]byte
@@ -219,7 +219,7 @@ func readField(r io.Reader) (v interface{}, err error) {
return readDecimal(r)
case 'S':
return readLongstr(r)
return readLongStr(r)
case 'A':
return readArray(r)
@@ -231,12 +231,12 @@ func readField(r io.Reader) (v interface{}, err error) {
return readTable(r)
case 'x':
var len int32
if err = binary.Read(r, binary.BigEndian, &len); err != nil {
var lenVal int32
if err = binary.Read(r, binary.BigEndian, &lenVal); err != nil {
return nil, err
}
value := make([]byte, len)
value := make([]byte, lenVal)
if _, err = io.ReadFull(r, value); err != nil {
return nil, err
}
@@ -261,7 +261,7 @@ func readTable(r io.Reader) (table Table, err error) {
var nested bytes.Buffer
var str string
if str, err = readLongstr(r); err != nil {
if str, err = readLongStr(r); err != nil {
return
}
@@ -273,7 +273,7 @@ func readTable(r io.Reader) (table Table, err error) {
var key string
var value interface{}
if key, err = readShortstr(&nested); err != nil {
if key, err = readShortStr(&nested); err != nil {
return
}
@@ -349,12 +349,12 @@ func (r *AmqpReader) parseHeaderFrame(channel uint16, size uint32) (frame frame,
}
if hasProperty(flags, flagContentType) {
if hf.Properties.ContentType, err = readShortstr(r.R); err != nil {
if hf.Properties.ContentType, err = readShortStr(r.R); err != nil {
return
}
}
if hasProperty(flags, flagContentEncoding) {
if hf.Properties.ContentEncoding, err = readShortstr(r.R); err != nil {
if hf.Properties.ContentEncoding, err = readShortStr(r.R); err != nil {
return
}
}
@@ -374,22 +374,22 @@ func (r *AmqpReader) parseHeaderFrame(channel uint16, size uint32) (frame frame,
}
}
if hasProperty(flags, flagCorrelationId) {
if hf.Properties.CorrelationId, err = readShortstr(r.R); err != nil {
if hf.Properties.CorrelationId, err = readShortStr(r.R); err != nil {
return
}
}
if hasProperty(flags, flagReplyTo) {
if hf.Properties.ReplyTo, err = readShortstr(r.R); err != nil {
if hf.Properties.ReplyTo, err = readShortStr(r.R); err != nil {
return
}
}
if hasProperty(flags, flagExpiration) {
if hf.Properties.Expiration, err = readShortstr(r.R); err != nil {
if hf.Properties.Expiration, err = readShortStr(r.R); err != nil {
return
}
}
if hasProperty(flags, flagMessageId) {
if hf.Properties.MessageId, err = readShortstr(r.R); err != nil {
if hf.Properties.MessageId, err = readShortStr(r.R); err != nil {
return
}
}
@@ -399,22 +399,22 @@ func (r *AmqpReader) parseHeaderFrame(channel uint16, size uint32) (frame frame,
}
}
if hasProperty(flags, flagType) {
if hf.Properties.Type, err = readShortstr(r.R); err != nil {
if hf.Properties.Type, err = readShortStr(r.R); err != nil {
return
}
}
if hasProperty(flags, flagUserId) {
if hf.Properties.UserId, err = readShortstr(r.R); err != nil {
if hf.Properties.UserId, err = readShortStr(r.R); err != nil {
return
}
}
if hasProperty(flags, flagAppId) {
if hf.Properties.AppId, err = readShortstr(r.R); err != nil {
if hf.Properties.AppId, err = readShortStr(r.R); err != nil {
return
}
}
if hasProperty(flags, flagReserved1) {
if hf.Properties.reserved1, err = readShortstr(r.R); err != nil {
if hf.Properties.reserved1, err = readShortStr(r.R); err != nil {
return
}
}
@@ -436,7 +436,7 @@ func (r *AmqpReader) parseBodyFrame(channel uint16, size uint32) (frame frame, e
return bf, nil
}
var errHeartbeatPayload = errors.New("Heartbeats should not have a payload")
var errHeartbeatPayload = errors.New("heartbeats should not have a payload")
func (r *AmqpReader) parseHeartbeatFrame(channel uint16, size uint32) (frame frame, err error) {
hf := &HeartbeatFrame{

View File

@@ -70,10 +70,10 @@ func (msg *ConnectionStart) read(r io.Reader) (err error) {
return
}
if msg.Mechanisms, err = readLongstr(r); err != nil {
if msg.Mechanisms, err = readLongStr(r); err != nil {
return
}
if msg.Locales, err = readLongstr(r); err != nil {
if msg.Locales, err = readLongStr(r); err != nil {
return
}
@@ -93,15 +93,15 @@ func (msg *ConnectionStartOk) read(r io.Reader) (err error) {
return
}
if msg.Mechanism, err = readShortstr(r); err != nil {
if msg.Mechanism, err = readShortStr(r); err != nil {
return
}
if msg.Response, err = readLongstr(r); err != nil {
if msg.Response, err = readLongStr(r); err != nil {
return
}
if msg.Locale, err = readShortstr(r); err != nil {
if msg.Locale, err = readShortStr(r); err != nil {
return
}
@@ -114,7 +114,7 @@ type connectionSecure struct {
func (msg *connectionSecure) read(r io.Reader) (err error) {
if msg.Challenge, err = readLongstr(r); err != nil {
if msg.Challenge, err = readLongStr(r); err != nil {
return
}
@@ -127,7 +127,7 @@ type connectionSecureOk struct {
func (msg *connectionSecureOk) read(r io.Reader) (err error) {
if msg.Response, err = readLongstr(r); err != nil {
if msg.Response, err = readLongStr(r); err != nil {
return
}
@@ -189,17 +189,17 @@ type connectionOpen struct {
func (msg *connectionOpen) read(r io.Reader) (err error) {
var bits byte
if msg.VirtualHost, err = readShortstr(r); err != nil {
if msg.VirtualHost, err = readShortStr(r); err != nil {
return
}
if msg.reserved1, err = readShortstr(r); err != nil {
if msg.reserved1, err = readShortStr(r); err != nil {
return
}
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.reserved2 = (bits&(1<<0) > 0)
msg.reserved2 = bits&(1<<0) > 0
return
}
@@ -210,7 +210,7 @@ type connectionOpenOk struct {
func (msg *connectionOpenOk) read(r io.Reader) (err error) {
if msg.reserved1, err = readShortstr(r); err != nil {
if msg.reserved1, err = readShortStr(r); err != nil {
return
}
@@ -230,7 +230,7 @@ func (msg *ConnectionClose) read(r io.Reader) (err error) {
return
}
if msg.ReplyText, err = readShortstr(r); err != nil {
if msg.ReplyText, err = readShortStr(r); err != nil {
return
}
@@ -258,7 +258,7 @@ type connectionBlocked struct {
func (msg *connectionBlocked) read(r io.Reader) (err error) {
if msg.Reason, err = readShortstr(r); err != nil {
if msg.Reason, err = readShortStr(r); err != nil {
return
}
@@ -279,7 +279,7 @@ type channelOpen struct {
func (msg *channelOpen) read(r io.Reader) (err error) {
if msg.reserved1, err = readShortstr(r); err != nil {
if msg.reserved1, err = readShortStr(r); err != nil {
return
}
@@ -292,7 +292,7 @@ type channelOpenOk struct {
func (msg *channelOpenOk) read(r io.Reader) (err error) {
if msg.reserved1, err = readLongstr(r); err != nil {
if msg.reserved1, err = readLongStr(r); err != nil {
return
}
@@ -309,7 +309,7 @@ func (msg *channelFlow) read(r io.Reader) (err error) {
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Active = (bits&(1<<0) > 0)
msg.Active = bits&(1<<0) > 0
return
}
@@ -324,7 +324,7 @@ func (msg *channelFlowOk) read(r io.Reader) (err error) {
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Active = (bits&(1<<0) > 0)
msg.Active = bits&(1<<0) > 0
return
}
@@ -342,7 +342,7 @@ func (msg *channelClose) read(r io.Reader) (err error) {
return
}
if msg.ReplyText, err = readShortstr(r); err != nil {
if msg.ReplyText, err = readShortStr(r); err != nil {
return
}
@@ -383,21 +383,21 @@ func (msg *ExchangeDeclare) read(r io.Reader) (err error) {
return
}
if msg.Exchange, err = readShortstr(r); err != nil {
if msg.Exchange, err = readShortStr(r); err != nil {
return
}
if msg.Type, err = readShortstr(r); err != nil {
if msg.Type, err = readShortStr(r); err != nil {
return
}
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Passive = (bits&(1<<0) > 0)
msg.Durable = (bits&(1<<1) > 0)
msg.AutoDelete = (bits&(1<<2) > 0)
msg.Internal = (bits&(1<<3) > 0)
msg.NoWait = (bits&(1<<4) > 0)
msg.Passive = bits&(1<<0) > 0
msg.Durable = bits&(1<<1) > 0
msg.AutoDelete = bits&(1<<2) > 0
msg.Internal = bits&(1<<3) > 0
msg.NoWait = bits&(1<<4) > 0
if msg.Arguments, err = readTable(r); err != nil {
return
@@ -428,15 +428,15 @@ func (msg *exchangeDelete) read(r io.Reader) (err error) {
return
}
if msg.Exchange, err = readShortstr(r); err != nil {
if msg.Exchange, err = readShortStr(r); err != nil {
return
}
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.IfUnused = (bits&(1<<0) > 0)
msg.NoWait = (bits&(1<<1) > 0)
msg.IfUnused = bits&(1<<0) > 0
msg.NoWait = bits&(1<<1) > 0
return
}
@@ -465,20 +465,20 @@ func (msg *exchangeBind) read(r io.Reader) (err error) {
return
}
if msg.Destination, err = readShortstr(r); err != nil {
if msg.Destination, err = readShortStr(r); err != nil {
return
}
if msg.Source, err = readShortstr(r); err != nil {
if msg.Source, err = readShortStr(r); err != nil {
return
}
if msg.RoutingKey, err = readShortstr(r); err != nil {
if msg.RoutingKey, err = readShortStr(r); err != nil {
return
}
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.NoWait = (bits&(1<<0) > 0)
msg.NoWait = bits&(1<<0) > 0
if msg.Arguments, err = readTable(r); err != nil {
return
@@ -511,20 +511,20 @@ func (msg *exchangeUnbind) read(r io.Reader) (err error) {
return
}
if msg.Destination, err = readShortstr(r); err != nil {
if msg.Destination, err = readShortStr(r); err != nil {
return
}
if msg.Source, err = readShortstr(r); err != nil {
if msg.Source, err = readShortStr(r); err != nil {
return
}
if msg.RoutingKey, err = readShortstr(r); err != nil {
if msg.RoutingKey, err = readShortStr(r); err != nil {
return
}
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.NoWait = (bits&(1<<0) > 0)
msg.NoWait = bits&(1<<0) > 0
if msg.Arguments, err = readTable(r); err != nil {
return
@@ -559,18 +559,18 @@ func (msg *QueueDeclare) read(r io.Reader) (err error) {
return
}
if msg.Queue, err = readShortstr(r); err != nil {
if msg.Queue, err = readShortStr(r); err != nil {
return
}
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Passive = (bits&(1<<0) > 0)
msg.Durable = (bits&(1<<1) > 0)
msg.Exclusive = (bits&(1<<2) > 0)
msg.AutoDelete = (bits&(1<<3) > 0)
msg.NoWait = (bits&(1<<4) > 0)
msg.Passive = bits&(1<<0) > 0
msg.Durable = bits&(1<<1) > 0
msg.Exclusive = bits&(1<<2) > 0
msg.AutoDelete = bits&(1<<3) > 0
msg.NoWait = bits&(1<<4) > 0
if msg.Arguments, err = readTable(r); err != nil {
return
@@ -587,7 +587,7 @@ type QueueDeclareOk struct {
func (msg *QueueDeclareOk) read(r io.Reader) (err error) {
if msg.Queue, err = readShortstr(r); err != nil {
if msg.Queue, err = readShortStr(r); err != nil {
return
}
@@ -617,20 +617,20 @@ func (msg *QueueBind) read(r io.Reader) (err error) {
return
}
if msg.Queue, err = readShortstr(r); err != nil {
if msg.Queue, err = readShortStr(r); err != nil {
return
}
if msg.Exchange, err = readShortstr(r); err != nil {
if msg.Exchange, err = readShortStr(r); err != nil {
return
}
if msg.RoutingKey, err = readShortstr(r); err != nil {
if msg.RoutingKey, err = readShortStr(r); err != nil {
return
}
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.NoWait = (bits&(1<<0) > 0)
msg.NoWait = bits&(1<<0) > 0
if msg.Arguments, err = readTable(r); err != nil {
return
@@ -661,13 +661,13 @@ func (msg *queueUnbind) read(r io.Reader) (err error) {
return
}
if msg.Queue, err = readShortstr(r); err != nil {
if msg.Queue, err = readShortStr(r); err != nil {
return
}
if msg.Exchange, err = readShortstr(r); err != nil {
if msg.Exchange, err = readShortStr(r); err != nil {
return
}
if msg.RoutingKey, err = readShortstr(r); err != nil {
if msg.RoutingKey, err = readShortStr(r); err != nil {
return
}
@@ -699,14 +699,14 @@ func (msg *queuePurge) read(r io.Reader) (err error) {
return
}
if msg.Queue, err = readShortstr(r); err != nil {
if msg.Queue, err = readShortStr(r); err != nil {
return
}
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.NoWait = (bits&(1<<0) > 0)
msg.NoWait = bits&(1<<0) > 0
return
}
@@ -739,16 +739,16 @@ func (msg *queueDelete) read(r io.Reader) (err error) {
return
}
if msg.Queue, err = readShortstr(r); err != nil {
if msg.Queue, err = readShortStr(r); err != nil {
return
}
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.IfUnused = (bits&(1<<0) > 0)
msg.IfEmpty = (bits&(1<<1) > 0)
msg.NoWait = (bits&(1<<2) > 0)
msg.IfUnused = bits&(1<<0) > 0
msg.IfEmpty = bits&(1<<1) > 0
msg.NoWait = bits&(1<<2) > 0
return
}
@@ -786,7 +786,7 @@ func (msg *basicQos) read(r io.Reader) (err error) {
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Global = (bits&(1<<0) > 0)
msg.Global = bits&(1<<0) > 0
return
}
@@ -817,20 +817,20 @@ func (msg *BasicConsume) read(r io.Reader) (err error) {
return
}
if msg.Queue, err = readShortstr(r); err != nil {
if msg.Queue, err = readShortStr(r); err != nil {
return
}
if msg.ConsumerTag, err = readShortstr(r); err != nil {
if msg.ConsumerTag, err = readShortStr(r); err != nil {
return
}
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.NoLocal = (bits&(1<<0) > 0)
msg.NoAck = (bits&(1<<1) > 0)
msg.Exclusive = (bits&(1<<2) > 0)
msg.NoWait = (bits&(1<<3) > 0)
msg.NoLocal = bits&(1<<0) > 0
msg.NoAck = bits&(1<<1) > 0
msg.Exclusive = bits&(1<<2) > 0
msg.NoWait = bits&(1<<3) > 0
if msg.Arguments, err = readTable(r); err != nil {
return
@@ -845,7 +845,7 @@ type BasicConsumeOk struct {
func (msg *BasicConsumeOk) read(r io.Reader) (err error) {
if msg.ConsumerTag, err = readShortstr(r); err != nil {
if msg.ConsumerTag, err = readShortStr(r); err != nil {
return
}
@@ -860,14 +860,14 @@ type basicCancel struct {
func (msg *basicCancel) read(r io.Reader) (err error) {
var bits byte
if msg.ConsumerTag, err = readShortstr(r); err != nil {
if msg.ConsumerTag, err = readShortStr(r); err != nil {
return
}
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.NoWait = (bits&(1<<0) > 0)
msg.NoWait = bits&(1<<0) > 0
return
}
@@ -878,7 +878,7 @@ type basicCancelOk struct {
func (msg *basicCancelOk) read(r io.Reader) (err error) {
if msg.ConsumerTag, err = readShortstr(r); err != nil {
if msg.ConsumerTag, err = readShortStr(r); err != nil {
return
}
@@ -910,18 +910,18 @@ func (msg *BasicPublish) read(r io.Reader) (err error) {
return
}
if msg.Exchange, err = readShortstr(r); err != nil {
if msg.Exchange, err = readShortStr(r); err != nil {
return
}
if msg.RoutingKey, err = readShortstr(r); err != nil {
if msg.RoutingKey, err = readShortStr(r); err != nil {
return
}
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Mandatory = (bits&(1<<0) > 0)
msg.Immediate = (bits&(1<<1) > 0)
msg.Mandatory = bits&(1<<0) > 0
msg.Immediate = bits&(1<<1) > 0
return
}
@@ -949,13 +949,13 @@ func (msg *basicReturn) read(r io.Reader) (err error) {
return
}
if msg.ReplyText, err = readShortstr(r); err != nil {
if msg.ReplyText, err = readShortStr(r); err != nil {
return
}
if msg.Exchange, err = readShortstr(r); err != nil {
if msg.Exchange, err = readShortStr(r); err != nil {
return
}
if msg.RoutingKey, err = readShortstr(r); err != nil {
if msg.RoutingKey, err = readShortStr(r); err != nil {
return
}
@@ -983,7 +983,7 @@ func (msg *BasicDeliver) setContent(props Properties, body []byte) {
func (msg *BasicDeliver) read(r io.Reader) (err error) {
var bits byte
if msg.ConsumerTag, err = readShortstr(r); err != nil {
if msg.ConsumerTag, err = readShortStr(r); err != nil {
return
}
@@ -994,12 +994,12 @@ func (msg *BasicDeliver) read(r io.Reader) (err error) {
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Redelivered = (bits&(1<<0) > 0)
msg.Redelivered = bits&(1<<0) > 0
if msg.Exchange, err = readShortstr(r); err != nil {
if msg.Exchange, err = readShortStr(r); err != nil {
return
}
if msg.RoutingKey, err = readShortstr(r); err != nil {
if msg.RoutingKey, err = readShortStr(r); err != nil {
return
}
@@ -1019,14 +1019,14 @@ func (msg *basicGet) read(r io.Reader) (err error) {
return
}
if msg.Queue, err = readShortstr(r); err != nil {
if msg.Queue, err = readShortStr(r); err != nil {
return
}
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.NoAck = (bits&(1<<0) > 0)
msg.NoAck = bits&(1<<0) > 0
return
}
@@ -1059,12 +1059,12 @@ func (msg *basicGetOk) read(r io.Reader) (err error) {
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Redelivered = (bits&(1<<0) > 0)
msg.Redelivered = bits&(1<<0) > 0
if msg.Exchange, err = readShortstr(r); err != nil {
if msg.Exchange, err = readShortStr(r); err != nil {
return
}
if msg.RoutingKey, err = readShortstr(r); err != nil {
if msg.RoutingKey, err = readShortStr(r); err != nil {
return
}
@@ -1081,7 +1081,7 @@ type basicGetEmpty struct {
func (msg *basicGetEmpty) read(r io.Reader) (err error) {
if msg.reserved1, err = readShortstr(r); err != nil {
if msg.reserved1, err = readShortStr(r); err != nil {
return
}
@@ -1103,7 +1103,7 @@ func (msg *basicAck) read(r io.Reader) (err error) {
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Multiple = (bits&(1<<0) > 0)
msg.Multiple = bits&(1<<0) > 0
return
}
@@ -1123,7 +1123,7 @@ func (msg *basicReject) read(r io.Reader) (err error) {
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Requeue = (bits&(1<<0) > 0)
msg.Requeue = bits&(1<<0) > 0
return
}
@@ -1138,7 +1138,7 @@ func (msg *basicRecoverAsync) read(r io.Reader) (err error) {
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Requeue = (bits&(1<<0) > 0)
msg.Requeue = bits&(1<<0) > 0
return
}
@@ -1153,7 +1153,7 @@ func (msg *basicRecover) read(r io.Reader) (err error) {
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Requeue = (bits&(1<<0) > 0)
msg.Requeue = bits&(1<<0) > 0
return
}
@@ -1182,8 +1182,8 @@ func (msg *basicNack) read(r io.Reader) (err error) {
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Multiple = (bits&(1<<0) > 0)
msg.Requeue = (bits&(1<<1) > 0)
msg.Multiple = bits&(1<<0) > 0
msg.Requeue = bits&(1<<1) > 0
return
}
@@ -1246,7 +1246,7 @@ func (msg *confirmSelect) read(r io.Reader) (err error) {
if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
return
}
msg.Nowait = (bits&(1<<0) > 0)
msg.Nowait = bits&(1<<0) > 0
return
}

View File

@@ -91,7 +91,7 @@ func (ga *Http2Assembler) readMessage() (streamID uint32, messageHTTP1 interface
// Exactly one Framer is used for each half connection.
// (Instead of creating a new Framer for each ReadFrame operation)
// This is needed in order to decompress the headers,
// because the compression context is updated with each requests/response.
// because the compression context is updated with each request/response.
frame, err := ga.framer.ReadFrame()
if err != nil {
return

View File

@@ -14,7 +14,7 @@ import (
"github.com/up9inc/mizu/tap/api"
)
var http10protocol api.Protocol = api.Protocol{
var http10protocol = api.Protocol{
Name: "http",
LongName: "Hypertext Transfer Protocol -- HTTP/1.0",
Abbreviation: "HTTP",
@@ -28,7 +28,7 @@ var http10protocol api.Protocol = api.Protocol{
Priority: 0,
}
var http11protocol api.Protocol = api.Protocol{
var http11protocol = api.Protocol{
Name: "http",
LongName: "Hypertext Transfer Protocol -- HTTP/1.1",
Abbreviation: "HTTP",
@@ -42,7 +42,7 @@ var http11protocol api.Protocol = api.Protocol{
Priority: 0,
}
var http2Protocol api.Protocol = api.Protocol{
var http2Protocol = api.Protocol{
Name: "http",
LongName: "Hypertext Transfer Protocol Version 2 (HTTP/2)",
Abbreviation: "HTTP/2",
@@ -56,7 +56,7 @@ var http2Protocol api.Protocol = api.Protocol{
Priority: 0,
}
var grpcProtocol api.Protocol = api.Protocol{
var grpcProtocol = api.Protocol{
Name: "http",
LongName: "Hypertext Transfer Protocol Version 2 (HTTP/2) [ gRPC over HTTP/2 ]",
Abbreviation: "gRPC",
@@ -70,7 +70,7 @@ var grpcProtocol api.Protocol = api.Protocol{
Priority: 0,
}
var graphQL1Protocol api.Protocol = api.Protocol{
var graphQL1Protocol = api.Protocol{
Name: "http",
LongName: "Hypertext Transfer Protocol -- HTTP/1.1 [ GraphQL over HTTP/1.1 ]",
Abbreviation: "GQL",
@@ -84,7 +84,7 @@ var graphQL1Protocol api.Protocol = api.Protocol{
Priority: 0,
}
var graphQL2Protocol api.Protocol = api.Protocol{
var graphQL2Protocol = api.Protocol{
Name: "http",
LongName: "Hypertext Transfer Protocol Version 2 (HTTP/2) [ GraphQL over HTTP/2 ]",
Abbreviation: "GQL",

View File

@@ -66,7 +66,7 @@ func filterRequestBody(request *http.Request, options *api.TrafficFilteringOptio
if err != nil {
return
}
filteredBody, err := filterHttpBody([]byte(body), contenType, options)
filteredBody, err := filterHttpBody(body, contenType, options)
if err == nil {
request.Body = ioutil.NopCloser(bytes.NewBuffer(filteredBody))
} else {
@@ -80,7 +80,7 @@ func filterResponseBody(response *http.Response, options *api.TrafficFilteringOp
if err != nil {
return
}
filteredBody, err := filterHttpBody([]byte(body), contentType, options)
filteredBody, err := filterHttpBody(body, contentType, options)
if err == nil {
response.Body = ioutil.NopCloser(bytes.NewBuffer(filteredBody))
} else {

View File

@@ -817,12 +817,12 @@ func representDeleteTopicsRequest(data map[string]interface{}) []interface{} {
repPayload, _ := json.Marshal([]api.TableData{
{
Name: "TopicNames",
Value: string(topicNames),
Value: topicNames,
Selector: `request.payload.topicNames`,
},
{
Name: "Topics",
Value: string(topics),
Value: topics,
Selector: `request.payload.topics`,
},
{

View File

@@ -10,7 +10,7 @@ import (
"github.com/up9inc/mizu/tap/api"
)
var _protocol api.Protocol = api.Protocol{
var _protocol = api.Protocol{
Name: "kafka",
LongName: "Apache Kafka Protocol",
Abbreviation: "KAFKA",

View File

@@ -56,6 +56,6 @@ func makeArray(t reflect.Type, n int) array {
func (a array) index(i int) value { return value{val: a.val.Index(i)} }
func indexOf(s reflect.StructField) index { return index(s.Index) }
func indexOf(s reflect.StructField) index { return s.Index }
func bytesToString(b []byte) string { return string(b) }

View File

@@ -10,7 +10,7 @@ import (
"github.com/up9inc/mizu/tap/api"
)
var protocol api.Protocol = api.Protocol{
var protocol = api.Protocol{
Name: "redis",
LongName: "Redis Serialization Protocol",
Abbreviation: "REDIS",

View File

@@ -4,7 +4,7 @@ type RedisType string
type RedisCommand string
type RedisKeyword string
var types map[rune]RedisType = map[rune]RedisType{
var types = map[rune]RedisType{
plusByte: "Simple String",
dollarByte: "Bulk String",
asteriskByte: "Array",
@@ -13,7 +13,7 @@ var types map[rune]RedisType = map[rune]RedisType{
notApplicableByte: "N/A",
}
var commands []RedisCommand = []RedisCommand{
var commands = []RedisCommand{
"PING",
"SET",
"GET",
@@ -200,7 +200,7 @@ var commands []RedisCommand = []RedisCommand{
"XCLAIM",
}
var keywords []RedisKeyword = []RedisKeyword{
var keywords = []RedisKeyword{
"AGGREGATE",
"ALPHA",
"ASC",