Skip to content

Instantly share code, notes, and snippets.

Created Mar 8, 2021
What would you like to do?
Golang: returns first n UTF-8 character at Most
func firstNUTF8AtMost(s string, n int) string {
i := 0
for j := range s {
if i >= n {
return s[:j]
return s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment