func (me *Channel) call(req message, res ...message) error {
	if err := me.send(me, req); err != nil {
		return err
	}
	if req.wait() {
		select {
		case e := <-me.errors:
			return e
		case msg := <-me.rpc:
			if msg != nil {
				for _, try := range res {
					if reflect.TypeOf(msg) == reflect.TypeOf(try) {
						vres := reflect.ValueOf(try).Elem()
						vmsg := reflect.ValueOf(msg).Elem()
						vres.Set(vmsg)
						return nil
					}
				}
				return ErrCommandInvalid
			} else {
				return ErrClosed
			}
		}
	}
	return nil
}
Performs a request/response call for when the message is not NoWait and is
specified as Synchronous.
package amqp
import (
	"reflect"
	"sync"
)
const frameHeaderSize = 1 + 2 + 4 + 1
type Channel struct {
	destructor sync.Once
	sendM      sync.Mutex  
	m          sync.Mutex  
	connection *Connection
	rpc       chan message
	consumers *consumers
	id uint16
	noNotify bool
	closes []chan *Error
	flows []chan bool
	returns []chan Return
	cancels []chan string
	confirms   *confirms
	confirming bool
	errors chan *Error
	recv func(*Channel, frame) error
	send func(*Channel, message) error
	message messageWithContent
	header  *headerFrame
	body    []byte
}
func newChannel(c *Connection, id uint16) *Channel {
	return &Channel{
		connection: c,
		id:         id,
		rpc:        make(chan message),
		consumers:  makeConsumers(),
		confirms:   newConfirms(),
		recv:       (*Channel).recvMethod,
		send:       (*Channel).sendOpen,
		errors:     make(chan *Error, 1),
	}
}
func (me *Channel) shutdown(e *Error) {
	me.destructor.Do(func() {
		me.m.Lock()
		defer me.m.Unlock()
		if e != nil {
			for _, c := range me.closes {
				c <- e
			}
		}
		me.send = (*Channel).sendClosed
		if e != nil {
			me.errors <- e
		}
		me.consumers.closeAll()
		for _, c := range me.closes {
			close(c)
		}
		for _, c := range me.flows {
			close(c)
		}
		for _, c := range me.returns {
			close(c)
		}
		for _, c := range me.cancels {
			close(c)
		}
		if me.confirms != nil {
			me.confirms.Close()
		}
		me.noNotify = true
	})
}
func (me *Channel) open() error {
	return me.call(&channelOpen{}, &channelOpenOk{})
}