SubString for go (works well with unicode)
1// SubString works well with unicode 2func SubString(str string, start int, length int) string { 3 r := []rune(str) 4 n := len(r) 5 if start >= n || length <= 0 { 6 return "" 7 } 8 9 if start < 0 { 10 start = 0 11 } 12 end := start + length 13 if end > n { 14 end = n 15 } 16 17 return string(r[start:end]) 18}