From 9a0e78056b6c012ffe933c83fea6e7f526e029cf Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Thu, 29 Feb 2024 07:19:12 -0500 Subject: [PATCH] Avoid floats and type conversions Signed-off-by: Matt Lord --- go/textutil/strings.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go/textutil/strings.go b/go/textutil/strings.go index 1b22231afa2..616366f0083 100644 --- a/go/textutil/strings.go +++ b/go/textutil/strings.go @@ -155,8 +155,8 @@ func TruncateText(text string, limit int, location TruncationLocation, indicator } switch location { case TruncationLocationMiddle: - prefix := int((float64(limit) * 0.5) - float64(len(indicator))) - suffix := int(ol - int(prefix+len(indicator)) + 1) + prefix := (limit / 2) - len(indicator) + suffix := (ol - (prefix + len(indicator))) + 1 return fmt.Sprintf("%s%s%s", text[:prefix], indicator, text[suffix:]), nil case TruncationLocationEnd: return text[:limit-(len(indicator)+1)] + indicator, nil