You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: router.go
    path of file: ./repos/plumber/vendor/github.com/eclipse/paho.mqtt.golang
    
    the code of the file until where you have to start completion: /*
 * Copyright (c) 2013 IBM Corp.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Seth Hoenig
 *    Allan Stockdill-Mander
 *    Mike Robertson
 */

package mqtt

import (
	"container/list"
	"strings"
	"sync"

	"github.com/eclipse/paho.mqtt.golang/packets"
)

// route is a type which associates MQTT Topic strings with a
// callback to be executed upon the arrival of a message associated
// with a subscription to that topic.
type route struct {
	topic    string
	callback MessageHandler
}

// match takes a slice of strings which represent the route being tested having been split on '/'
// 
    
func (r *router) matchAndDispatch(messages <-chan *packets.PublishPacket, order bool, client *client) {
	go func() {
		for {
			select {
			case message := <-messages:
				sent := false
				r.RLock()
				m := messageFromPublish(message, client.ackFunc(message))
				handlers := []MessageHandler{}
				for e := r.routes.Front(); e != nil; e = e.Next() {
					if e.Value.(*route).match(message.TopicName) {
						if order {
							handlers = append(handlers, e.Value.(*route).callback)
						} else {
							hd := e.Value.(*route).callback
							go func() {
								hd(client, m)
								m.Ack()
							}()
						}
						sent = true
					}
				}
				if !sent && r.defaultHandler != nil {
					if order {
						handlers = append(handlers, r.defaultHandler)
					} else {
						go func() {
							r.defaultHandler(client, m)
							m.Ack()
						}()
					}
				}
				r.RUnlock()
				for _, handler := range handlers {
					func() {
						handler(client, m)
						m.Ack()
					}()
				}
			case <-r.stop:
				return
			}
		}
	}()
}