refactor: remove redundant len check (#1743)

`len` returns 0 if the slice is nil. From the Go specification [1]:

  "1. For a nil slice, 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:
Eng Zer Jun
2023-09-26 17:00:05 +08:00
committed by GitHub
parent b43c1b9984
commit c1854a3a7b
4 changed files with 39 additions and 47 deletions

View File

@@ -1183,10 +1183,8 @@ func (l *base) execExternalPortScan(scanDestIPPorts map[string][]string) ([]stri
func formatNmapOptionsToString(conf *config.PortScanConf) string {
cmd := []string{conf.ScannerBinPath}
if len(conf.ScanTechniques) != 0 {
for _, technique := range conf.ScanTechniques {
cmd = append(cmd, "-"+technique)
}
for _, technique := range conf.ScanTechniques {
cmd = append(cmd, "-"+technique)
}
if conf.SourcePort != "" {