func readTable(r io.Reader) (table Table, err error) {
	var nested bytes.Buffer
	var str string
	if str, err = readLongstr(r); err != nil {
		return
	}
	nested.Write([]byte(str))
	table = make(Table)
	for nested.Len() > 0 {
		var key string
		var value interface{}
		if key, err = readShortstr(&nested); err != nil {
			return
		}
		if value, err = readField(&nested); err != nil {
			return
		}
		table[key] = value
	}
	return
}
/*
Field tables are long strings that contain packed name-value pairs.  The
name-value pairs are encoded as short string defining the name, and octet
defining the values type and then the value itself.   The valid field types for
tables are an extension of the native integer, bit, string, and timestamp
types, and are shown in the grammar.  Multi-octet integer fields are always
held in network byte order.
package main
import (
	"bytes"
	"encoding/binary"
	"errors"
	"io"
	"time"
)
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])
	channel := binary.BigEndian.Uint16(scratch[1:3])
	size := binary.BigEndian.Uint32(scratch[3:7])
	if size > 1000000*16 {
		return nil, ErrMaxSize
	}
	switch typ {
	case frameMethod:
		if frame, err = r.parseMethodFrame(channel, size); err != nil {
			return
		}
	case frameHeader:
		if frame, err = r.parseHeaderFrame(channel, size); err != nil {
			return
		}
	case frameBody:
		if frame, err = r.parseBodyFrame(channel, size); err != nil {
			return nil, err
		}
	case frameHeartbeat:
		if frame, err = r.parseHeartbeatFrame(channel, size); err != nil {
			return
		}
	default:
		return nil, ErrFrame
	}
	if _, err = io.ReadFull(r.R, scratch[:1]); err != nil {
		return nil, err
	}
	if scratch[0] != frameEnd {
		return nil, ErrFrame
	}
	return
}
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 {
		return
	}
	return string(bytes), nil
}
func readLongstr(r io.Reader) (v string, err error) {
	var length uint32
	if err = binary.Read(r, binary.BigEndian, &length); err != nil {
		return
	}
	if length > (^uint32(0) >> 1) {
		return
	}
	bytes := make([]byte, length)
	if _, err = io.ReadFull(r, bytes); err != nil {
		return
	}
	return string(bytes), nil
}
func readDecimal(r io.Reader) (v Decimal, err error) {
	if err = binary.Read(r, binary.BigEndian, &v.Scale); err != nil {
		return
	}
	if err = binary.Read(r, binary.BigEndian, &v.Value); err != nil {
		return
	}
	return
}
func readFloat32(r io.Reader) (v float32, err error) {
	if err = binary.Read(r, binary.BigEndian, &v); err != nil {
		return
	}
	return
}
func readFloat64(r io.Reader) (v float64, err error) {
	if err = binary.Read(r, binary.BigEndian, &v); err != nil {
		return
	}
	return
}
func readTimestamp(r io.Reader) (v time.Time, err error) {
	var sec int64
	if err = binary.Read(r, binary.BigEndian, &sec); err != nil {
		return
	}
	return time.Unix(sec, 0), nil
}
func readField(r io.Reader) (v interface{}, err error) {
	var typ byte
	if err = binary.Read(r, binary.BigEndian, &typ); err != nil {
		return
	}
	switch typ {
	case 't':
		var value uint8
		if err = binary.Read(r, binary.BigEndian, &value); err != nil {
			return
		}
		return (value != 0), nil
	case 'b':
		var value [1]byte
		if _, err = io.ReadFull(r, value[0:1]); err != nil {
			return
		}
		return value[0], nil
	case 's':
		var value int16
		if err = binary.Read(r, binary.BigEndian, &value); err != nil {
			return
		}
		return value, nil
	case 'I':
		var value int32
		if err = binary.Read(r, binary.BigEndian, &value); err != nil {
			return
		}
		return value, nil
	case 'l':
		var value int64
		if err = binary.Read(r, binary.BigEndian, &value); err != nil {
			return
		}
		return value, nil
	case 'f':
		var value float32
		if err = binary.Read(r, binary.BigEndian, &value); err != nil {
			return
		}
		return value, nil
	case 'd':
		var value float64
		if err = binary.Read(r, binary.BigEndian, &value); err != nil {
			return
		}
		return value, nil
	case 'D':
		return readDecimal(r)
	case 'S':
		return readLongstr(r)
	case 'A':
		return readArray(r)
	case 'T':
		return readTimestamp(r)
	case 'F':
		return readTable(r)
	case 'x':
		var len int32
		if err = binary.Read(r, binary.BigEndian, &len); err != nil {
			return nil, err
		}
		value := make([]byte, len)
		if _, err = io.ReadFull(r, value); err != nil {
			return nil, err
		}
		return value, err
	case 'V':
		return nil, nil
	}
	return nil, ErrSyntax
}