Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Commit dbb3f0a

Browse files
committed
use the range keyword instead of for with len
1 parent ab8c02c commit dbb3f0a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pkg/teler/utils.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ import (
1111

1212
func getDatasets() {
1313
datasets = make(map[string]map[string]string)
14+
1415
rsc := resource.Get()
15-
for i := 0; i < len(rsc.Threat); i++ {
16-
threat := reflect.ValueOf(&rsc.Threat[i]).Elem()
17-
cat := threat.FieldByName("Category").String()
18-
con := threat.FieldByName("Content").String()
16+
for _, threat := range rsc.Threat {
17+
thr := reflect.ValueOf(threat)
18+
cat := thr.FieldByName("Category").String()
19+
con := thr.FieldByName("Content").String()
1920

20-
if threat.FieldByName("Exclude").Bool() {
21+
if thr.FieldByName("Exclude").Bool() {
2122
continue
2223
}
2324

@@ -33,8 +34,8 @@ func trimFirst(s string) string {
3334

3435
func isWhitelist(options *common.Options, find string) bool {
3536
whitelist := options.Configs.Rules.Threat.Whitelists
36-
for i := 0; i < len(whitelist); i++ {
37-
match := matchers.IsMatch(whitelist[i], find)
37+
for _, item := range whitelist {
38+
match := matchers.IsMatch(item, find)
3839
if match {
3940
return true
4041
}

0 commit comments

Comments
 (0)