TruncateAt returns the first n bytes of s. It returns empty string when s is empty or n is less than one.
(s string, n int)
| 7 | // TruncateAt returns the first n bytes of s. |
| 8 | // It returns empty string when s is empty or n is less than one. |
| 9 | func TruncateAt(s string, n int) string { |
| 10 | return s[:max(0, min(n, len(s)))] |
| 11 | } |
no outgoing calls