Truncate truncates the given text to the provided limit, returning the original string if it's shorter than the limit.
(s string, l int)
| 83 | |
| 84 | // Truncate truncates the given text to the provided limit, returning the original string if it's shorter than the limit. |
| 85 | func Truncate(s string, l int) string { |
| 86 | c := []rune(s) |
| 87 | if len(c) > l { |
| 88 | s = string(c[:l]) |
| 89 | } |
| 90 | return s |
| 91 | } |