init
This commit is contained in:
17
bbs-go/server/internal/pkg/text/text.go
Normal file
17
bbs-go/server/internal/pkg/text/text.go
Normal file
@@ -0,0 +1,17 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user