mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 09:07:21 +01:00
refactor: remove redundant len
check (#2291)
`len` returns 0 if the slice or map is nil. From the Go specification [1]: "1. For a nil slice, the number of iterations is 0." "3. If the map is nil, the number of iterations is 0." Therefore, an additional `len(v) != 0` check for before the loop is unnecessary. [1]: https://go.dev/ref/spec#For_range Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
parent
299aa1e123
commit
a1121556be
2
get.go
2
get.go
@ -26,11 +26,9 @@ func printPkgbuilds(dbExecutor download.DBSearcher, aurClient aur.QueryClient,
|
|||||||
logger.Errorln(err)
|
logger.Errorln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(pkgbuilds) != 0 {
|
|
||||||
for target, pkgbuild := range pkgbuilds {
|
for target, pkgbuild := range pkgbuilds {
|
||||||
logger.Printf("\n\n# %s\n\n%s", target, string(pkgbuild))
|
logger.Printf("\n\n# %s\n\n%s", target, string(pkgbuild))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if len(pkgbuilds) != len(targets) {
|
if len(pkgbuilds) != len(targets) {
|
||||||
missing := []string{}
|
missing := []string{}
|
||||||
|
2
query.go
2
query.go
@ -80,11 +80,9 @@ func syncInfo(ctx context.Context, run *runtime.Runtime,
|
|||||||
missing = true
|
missing = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(info) != 0 {
|
|
||||||
for i := range info {
|
for i := range info {
|
||||||
printInfo(run.Logger, run.Cfg, &info[i], cmdArgs.ExistsDouble("i"))
|
printInfo(run.Logger, run.Cfg, &info[i], cmdArgs.ExistsDouble("i"))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if missing {
|
if missing {
|
||||||
err = fmt.Errorf("")
|
err = fmt.Errorf("")
|
||||||
|
Loading…
Reference in New Issue
Block a user