From 665724b3741c098700a68ae5fa208103f01235a6 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Sun, 8 Dec 2024 23:49:44 +0200 Subject: [PATCH] dev: simplify cutVal implementation --- pkg/printers/teamcity.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/printers/teamcity.go b/pkg/printers/teamcity.go index 1d1c9f7d32e1..83c4959114f4 100644 --- a/pkg/printers/teamcity.go +++ b/pkg/printers/teamcity.go @@ -4,7 +4,6 @@ import ( "fmt" "io" "strings" - "unicode/utf8" "github.com/golangci/golangci-lint/pkg/result" ) @@ -112,11 +111,9 @@ func (i InspectionInstance) Print(w io.Writer, replacer *strings.Replacer) (int, } func cutVal(s string, limit int) string { - var size, count int - for i := 0; i < limit && count < len(s); i++ { - _, size = utf8.DecodeRuneInString(s[count:]) - count += size + runes := []rune(s) + if len(runes) > limit { + return string(runes[:limit]) } - - return s[:count] + return s }