github.com/jtzjtz/kit@v1.0.2/str/str.go (about) 1 package str 2 3 import "fmt" 4 5 //反转字符串 6 func ReverseString(s string) string { 7 runes := []rune(s) 8 9 for from, to := 0, len(runes)-1; from < to; from, to = from+1, to-1 { 10 runes[from], runes[to] = runes[to], runes[from] 11 } 12 return string(runes) 13 } 14 15 //map转string 16 func MapToString(m map[string]interface{}, spilt_str string) string { 17 str := "" 18 for k, v := range m { 19 str += fmt.Sprintf("%s:%s %s", k, v, spilt_str) 20 } 21 return str 22 }