From a91af5b1eedadb276ac115e6bfc053b1342e723f Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 19:22:39 +0100 Subject: [PATCH] bug: fix slice init length (#40637) (#41515) Signed-off-by: dufucun Co-authored-by: Mauri de Souza Meneguzzo Co-authored-by: Anderson Queiroz (cherry picked from commit 092929bd6b57ca9022288f2704226966d9db803a) Co-authored-by: dufucun --- libbeat/processors/fingerprint/fingerprint_test.go | 2 +- libbeat/processors/ratelimit/limit.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libbeat/processors/fingerprint/fingerprint_test.go b/libbeat/processors/fingerprint/fingerprint_test.go index 5f6bdb70b5e..8d66762e479 100644 --- a/libbeat/processors/fingerprint/fingerprint_test.go +++ b/libbeat/processors/fingerprint/fingerprint_test.go @@ -505,7 +505,7 @@ func nRandomEvents(num int) []beat.Event { charsetLen := len(charset) b := make([]byte, 200) - events := make([]beat.Event, num) + events := make([]beat.Event, 0, num) for i := 0; i < num; i++ { for j := range b { b[j] = charset[prng.Intn(charsetLen)] diff --git a/libbeat/processors/ratelimit/limit.go b/libbeat/processors/ratelimit/limit.go index 0d6f14d88d7..c989e4a2527 100644 --- a/libbeat/processors/ratelimit/limit.go +++ b/libbeat/processors/ratelimit/limit.go @@ -52,7 +52,7 @@ func (l *rate) Unpack(str string) error { } if allowed := []unit{unitPerSecond, unitPerMinute, unitPerHour}; !contains(allowed, unitStr) { - allowedStrs := make([]string, len(allowed)) + allowedStrs := make([]string, 0, len(allowed)) for _, a := range allowed { allowedStrs = append(allowedStrs, "/"+string(a)) }