File: stringsextra.go

package info (click to toggle)
fq 0.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 106,624 kB
  • sloc: xml: 2,835; makefile: 250; sh: 241; exp: 57; ansic: 21
file content (11 lines) | stat: -rw-r--r-- 223 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
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
}