func (u *URLList) Get(url string) []string {
	u.mu.Lock()
	uses := u.Urls[url]
	u.mu.Unlock()
	return uses
}
Get the uses of a url
package main
import (
	"encoding/gob"
	"flag"
	"fmt"
	"log"
	"os"
	"regexp"
	"sync"
)
type URLList struct {
	Urls map[string][]string
	mu   sync.Mutex
}
var (
	httpPort    int
	stateFile   string
	botUsername string
	urlsUsed *URLList
	urlRegex *regexp.Regexp
)
func init() {
	urlRegex = regexp.MustCompile(`<(http([^\||>]*))`)
}
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: ./slack-oldbot -port=8001\n")
		flag.PrintDefaults()
	}
	flag.IntVar(&httpPort, "port", 8001, "The HTTP port on which to listen")
	flag.StringVar(&stateFile, "stateFile", "state", "File to use for maintaining our url list state")
	flag.StringVar(&botUsername, "botUsername", "oldbot", "The name of the bot when it speaks")
	var importDir = flag.String("importDir", "", "The directory of a Slack export")
	var importChan = flag.String("importChan", "", "Optional channel to limit the import to")
	flag.Parse()
	if httpPort == 0 {
		flag.Usage()
		os.Exit(2)
	}
	urlsUsed = &URLList{
		Urls: make(map[string][]string),
	}
	if *importDir != "" {
		err := StartImport(importDir, importChan)
		if err != nil {
			log.Fatal(err)
		}
	} else {
		err := urlsUsed.Load(stateFile)
		if err != nil {
			log.Printf("Could not load from '%s'. This may be expected.", stateFile)
		} else {
			log.Printf("Loaded previous state from '%s'.", stateFile)
		}
	}
	StartServer(httpPort)
}
func extractUrls(s string) (urls []string) {
	matches := urlRegex.FindAllStringSubmatch(s, -1)
	for _, match := range matches {
		if match[1] != "" {
			urls = append(urls, match[1])
		}
	}
	return
}
func (u *URLList) Add(url string, ts string) {
	u.mu.Lock()
	u.Urls[url] = append(u.Urls[url], ts)
	u.mu.Unlock()
}