pm/installed.go

25 lines
404 B
Go
Raw Normal View History

2018-03-06 00:02:36 -08:00
package pm
2018-03-06 00:10:46 -08:00
import "sort"
2018-03-06 00:02:36 -08:00
// Installed tracks installed packages.
type Installed map[Name]Meta
2018-03-06 00:10:46 -08:00
// Traverse returns a chan of Meta that will be sanely sorted.
func (i Installed) Traverse() <-chan Meta {
r := make(chan Meta)
go func() {
names := Names{}
for n := range i {
names = append(names, n)
}
sort.Sort(names)
for _, n := range names {
r <- i[n]
}
close(r)
}()
return r
}