1
1
mirror of https://github.com/wader/fq.git synced 2024-12-26 23:15:04 +03:00
fq/internal/stringsex/stringsextra.go

12 lines
223 B
Go

package stringsex
import "github.com/wader/fq/internal/mathex"
func TrimN(s string, n int, suffix string) string {
sl, tl := len(s), len(suffix)
if sl+tl <= n {
return s
}
return s[0:mathex.Max(n-tl, 0)] + suffix
}