func (q *Queue) pump() {
pump:
	for {
		if q.head == nil {
			newMessage, ok := <-q.InputChannel
			newQueueMessage := newQueueMessage(newMessage)
			if !ok {
				break pump  
			}
			q.head = newQueueMessage
			q.tail = newQueueMessage
			q.length++
		}
		select {
		case newMessage, ok := <-q.InputChannel:
			if !ok {
				break pump  
			}
			newQueueMessage := newQueueMessage(newMessage)
			q.tail.next = newQueueMessage
			q.tail = newQueueMessage
			q.length++
		case q.OutputChannel <- q.head.data:
			q.head = q.head.next
			q.length--
		}
	}
	nextMessageToSend := q.head
	for nextMessageToSend != nil {
		q.OutputChannel <- nextMessageToSend.data
		nextMessageToSend = nextMessageToSend.next
	}
	close(q.OutputChannel)
}
Run in a goroutine - receives and transmits messages on the channels
package queue
import (
	"github.com/FireEater64/gamq/message"
)
type Queue struct {
	Name          string
	InputChannel  chan *message.Message
	OutputChannel chan *message.Message
	head          *queueMessage
	tail          *queueMessage
	length        int
}
func NewQueue(givenName string) *Queue {
	q := Queue{}
	q.InputChannel = make(chan *message.Message)
	q.OutputChannel = make(chan *message.Message)
	go q.pump()
	return &q
}