Slice by runes — byte slicing can split a multi-byte UTF-8 sequence.
(msg string)
| 5 | |
| 6 | // Slice by runes — byte slicing can split a multi-byte UTF-8 sequence. |
| 7 | func truncateCommitMessage(msg string) string { |
| 8 | runes := []rune(msg) |
| 9 | if len(runes) > commitMessageMaxRunes { |
| 10 | return string(runes[:commitMessageMaxRunes]) |
| 11 | } |
| 12 | return msg |
| 13 | } |
no outgoing calls