Refactoring inline functions

This commit is contained in:
Jguer 2017-05-07 20:24:18 +01:00
parent 1a58017817
commit c06b55d6f1

View File

@ -108,14 +108,19 @@ func PackageSlices(toCheck []string) (aur []string, repo []string, err error) {
for _, pkg := range toCheck { for _, pkg := range toCheck {
found := false found := false
for _, db := range dbList.Slice() {
_ = dbList.ForEach(func(db alpm.Db) error {
if found {
return nil
}
_, err = db.PkgByName(pkg) _, err = db.PkgByName(pkg)
if err == nil { if err == nil {
found = true found = true
repo = append(repo, pkg) repo = append(repo, pkg)
break
} }
} return nil
})
if !found { if !found {
if _, errdb := dbList.PkgCachebyGroup(pkg); errdb == nil { if _, errdb := dbList.PkgCachebyGroup(pkg); errdb == nil {
@ -231,7 +236,7 @@ func ForeignPackages() (foreign map[string]alpm.Package, err error) {
f := func(k alpm.Package) error { f := func(k alpm.Package) error {
found := false found := false
dbList.ForEach(func(d alpm.Db) error { _ = dbList.ForEach(func(d alpm.Db) error {
if found { if found {
return nil return nil
} }
@ -397,25 +402,20 @@ func CreatePackageList(out *os.File) (err error) {
return return
} }
p := func(pkg alpm.Package) error { _ = dbList.ForEach(func(db alpm.Db) error {
fmt.Print(pkg.Name()) _ = db.PkgCache().ForEach(func(pkg alpm.Package) error {
out.WriteString(pkg.Name()) fmt.Print(pkg.Name())
if config.YayConf.Shell == "fish" { out.WriteString(pkg.Name())
fmt.Print("\t" + pkg.DB().Name() + "\n") if config.YayConf.Shell == "fish" {
out.WriteString("\t" + pkg.DB().Name() + "\n") fmt.Print("\t" + pkg.DB().Name() + "\n")
} else { out.WriteString("\t" + pkg.DB().Name() + "\n")
fmt.Print("\n") } else {
out.WriteString("\n") fmt.Print("\n")
} out.WriteString("\n")
}
return nil
})
return nil return nil
} })
f := func(db alpm.Db) error {
db.PkgCache().ForEach(p)
return nil
}
dbList.ForEach(f)
return nil return nil
} }