mirror of
https://github.com/wader/fq.git
synced 2024-11-22 15:45:45 +03:00
12 lines
223 B
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
|
|
}
|