package router import ( "strings" "time" "go.jolheiser.com/vanity/flags" "go.jolheiser.com/vanity/service" "go.jolheiser.com/beaver" ) var svc service.Service func cronStart() { ticker := time.NewTicker(flags.Config.Interval) for { <-ticker.C beaver.Debug("Running package update...") cronUpdate() beaver.Debugf("Finished package update: %s", cache.Names()) } } func cronUpdate() { packages, err := svc.Packages() if err != nil { beaver.Errorf("could not update packages: %v", err) return } // Filter for name, pkg := range packages { if err := service.Check(pkg); err != nil { beaver.Debug(err) delete(packages, name) continue } if !svc.GoMod(pkg) { beaver.Debugf("%s isn't a Go project", pkg.Name) delete(packages, name) continue } beaver.Debugf("Including %s", pkg.Name) } // Overrides for name, pkg := range packages { for key, override := range flags.Config.Overrides { if strings.EqualFold(name, key) { beaver.Debugf("Overriding %s -> %s", name, override.Name) delete(packages, key) pkg.Name = override.Name packages[override.Name] = pkg } } } cache.Update(packages) }