1
0

Check if package already in slice

This commit is contained in:
dump_stack() 2023-05-11 21:20:00 +00:00
parent 27a22ba023
commit f6cb2d8d12
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

View File

@ -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)
} }