From 5e0cbd93bea68074a1b70273b55df30b36ff6122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 11 Sep 2025 09:49:24 +0200 Subject: [PATCH] make firstNRunes more readable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- pkg/generators/natsnames.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/generators/natsnames.go b/pkg/generators/natsnames.go index 7220c1f9c..1a64d4423 100644 --- a/pkg/generators/natsnames.go +++ b/pkg/generators/natsnames.go @@ -33,12 +33,9 @@ func GenerateConnectionName(service string, ntype NType) string { // firstNRunes returns the first n runes of a string func firstNRunes(s string, n int) string { - i := 0 - for j := range s { - if i == n { - return s[:j] - } - i++ + runes := []rune(s) + if n > len(runes) { + n = len(runes) } - return s + return string(runes[:n]) }