From 3988733c3132ec5d2d582cc05c0fd2af10849022 Mon Sep 17 00:00:00 2001 From: beer-psi Date: Sun, 2 Nov 2025 09:15:04 +0700 Subject: [PATCH] lint: remove unused import --- core/share.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/core/share.go b/core/share.go index 530c6e324..c46b40a95 100644 --- a/core/share.go +++ b/core/share.go @@ -4,7 +4,6 @@ import ( "context" "strings" "time" - "unicode/utf8" "github.com/Masterminds/squirrel" "github.com/deluan/rest" @@ -121,8 +120,19 @@ func (r *shareRepositoryWrapper) Save(entity interface{}) (string, error) { return "", model.ErrNotFound } - if utf8.RuneCountInString(s.Contents) > 30 { - s.Contents = string([]rune(s.Contents)[:26]) + "..." + var runeCount int + var truncateIndex int + + for i := range s.Contents { + runeCount++ + + if runeCount == 27 { + truncateIndex = i + } + } + + if runeCount > 30 { + s.Contents = s.Contents[:truncateIndex] + "..." } id, err = r.Persistable.Save(s)