Skip to content

Commit 681d88b

Browse files
committed
Use 'nil' instead of empty map in 'catcher' calls system. Improve code readability and reduce memory allocation overhead.
1 parent 14217a4 commit 681d88b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

correlation/geo/bases.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func Load() {
4242
catcher.Info("asnBlocks rows", map[string]any{"count": len(asnBlocks)})
4343
catcher.Info("cityBlocks rows", map[string]any{"count": len(cityBlocks)})
4444
catcher.Info("cityLocations rows", map[string]any{"count": len(cityLocations)})
45-
catcher.Info("GeoIP databases loaded", map[string]any{})
45+
catcher.Info("GeoIP databases loaded", nil)
4646
}
4747

4848
func populateASNBlocks(csv [][]string) {

correlation/rules/rules.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func Changes(signals chan os.Signal) {
101101
cnf := utils.GetConfig()
102102
watcher, err := fsnotify.NewWatcher()
103103
if err != nil {
104-
catcher.Error("Could not create a new watcher", err, map[string]any{})
104+
catcher.Error("Could not create a new watcher", err, nil)
105105
}
106106
defer watcher.Close()
107107

@@ -111,16 +111,16 @@ func Changes(signals chan os.Signal) {
111111
select {
112112
case err, ok := <-watcher.Errors:
113113
if !ok {
114-
catcher.Error("Could not detect changes in ruleset", err, map[string]any{})
114+
catcher.Error("Could not detect changes in ruleset", err, nil)
115115
}
116116
case event, ok := <-watcher.Events:
117117
if !ok {
118-
catcher.Error("Error trying to detect changes in ruleset", err, map[string]any{})
118+
catcher.Error("Error trying to detect changes in ruleset", err, nil)
119119
}
120120
if event.Op&fsnotify.Write == fsnotify.Write {
121121
if event.Name != cnf.RulesFolder+"system/.git/FETCH_HEAD" {
122122
catcher.Info("Changes detected in", map[string]any{"file": event.Name})
123-
catcher.Info("Restarting correlation engine", map[string]any{})
123+
catcher.Info("Restarting correlation engine", nil)
124124
signals <- os.Interrupt
125125
}
126126
}
@@ -134,7 +134,7 @@ func Changes(signals chan os.Signal) {
134134
for {
135135
err := filepath.Walk(cnf.RulesFolder, func(path string, info os.FileInfo, err error) error {
136136
if err != nil {
137-
catcher.Error("Could not list rules folders", err, map[string]any{})
137+
catcher.Error("Could not list rules folders", err, nil)
138138
}
139139
n := true
140140
if info.IsDir() {
@@ -147,15 +147,15 @@ func Changes(signals chan os.Signal) {
147147
if n {
148148
folders = append(folders, path)
149149
if err := watcher.Add(path); err != nil {
150-
catcher.Error("Could not start watcher for a rules folder", err, map[string]any{})
150+
catcher.Error("Could not start watcher for a rules folder", err, nil)
151151
}
152152

153153
}
154154
}
155155
return nil
156156
})
157157
if err != nil {
158-
catcher.Error("Could not list rules folders", err, map[string]any{})
158+
catcher.Error("Could not list rules folders", err, nil)
159159
continue
160160
}
161161

0 commit comments

Comments
 (0)