Check if package already in slice
This commit is contained in:
parent
27a22ba023
commit
f6cb2d8d12
@ -274,6 +274,15 @@ func httpGetWithRetry(query string) (resp *http.Response, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func contains(pkgs []Package, pkg Package) bool {
|
||||||
|
for _, p := range pkgs {
|
||||||
|
if p.Name == pkg.Name {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func Packages(srcname, version, arch, regex string) (pkgs []Package, err error) {
|
func Packages(srcname, version, arch, regex string) (pkgs []Package, err error) {
|
||||||
binpkgs, err := mr.GetBinpackages(srcname, version)
|
binpkgs, err := mr.GetBinpackages(srcname, version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -295,6 +304,11 @@ func Packages(srcname, version, arch, regex string) (pkgs []Package, err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if contains(pkgs, pkg) {
|
||||||
|
log.Trace().Msgf("%v already in slice O_o", pkg.Name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
log.Trace().Msgf("append %v", pkg.Name)
|
log.Trace().Msgf("append %v", pkg.Name)
|
||||||
pkgs = append(pkgs, pkg)
|
pkgs = append(pkgs, pkg)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user