make firstNRunes more readable

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2025-09-11 09:49:24 +02:00
parent e7a6d9923c
commit 5e0cbd93be

View File

@@ -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])
}