in internal/encoding/types.go [202:234]
func PeekMessageType(buf []byte) (uint8, uint8, error) {
if len(buf) < 3 {
return 0, 0, errors.New("invalid message")
}
if buf[0] != 0 {
return 0, 0, fmt.Errorf("invalid composite header %02x", buf[0])
}
// copied from readUlong to avoid allocations
t := AMQPType(buf[1])
if t == TypeCodeUlong0 {
return 0, 2, nil
}
if t == TypeCodeSmallUlong {
if len(buf[2:]) == 0 {
return 0, 0, errors.New("invalid ulong")
}
return buf[2], 3, nil
}
if t != TypeCodeUlong {
return 0, 0, fmt.Errorf("invalid type for uint32 %02x", t)
}
if len(buf[2:]) < 8 {
return 0, 0, errors.New("invalid ulong")
}
v := binary.BigEndian.Uint64(buf[2:10])
return uint8(v), 10, nil
}