package router import ( "sync" "go.jolheiser.com/vanity/api" ) var cache = &packageCache{ packages: make(map[string]*api.Package), } type packageCache struct { packages map[string]*api.Package sync.Mutex } func (c *packageCache) Update(packages map[string]*api.Package) { c.Lock() c.packages = packages c.Unlock() } func (c *packageCache) Names() []string { names := make([]string, len(c.packages)) idx := 0 for name := range c.packages { names[idx] = name idx++ } return names }