Files
common-server-public/bbs-go-active/server/internal/pkg/text/text.go
2025-03-03 17:43:50 +08:00

18 lines
290 B
Go

package text
import (
"strings"
"github.com/mlogclub/simple/common/strs"
)
// GetSummary 获取summary
func GetSummary(s string, length int) string {
s = strings.TrimSpace(s)
summary := strs.Substr(s, 0, length)
if strs.RuneLen(s) > length {
summary += "..."
}
return summary
}