github.com/tickstep/library-go@v0.1.1/text/strlib.go (about) 1 package text 2 3 // Substr2 截取字符串 start 起点下标 end 终点下标(不包括) 4 func Substr(str string, start int, end int) string { 5 rs := []rune(str) 6 length := len(rs) 7 8 if start < 0 || start > length { 9 panic("start is wrong") 10 } 11 12 if end < 0 || end > length { 13 panic("end is wrong") 14 } 15 16 return string(rs[start:end]) 17 }