github.com/hungdoo/bot@v0.0.0-20240325145135-dd1f386f7b81/src/packages/utils/string.go (about) 1 package utils 2 3 import ( 4 "fmt" 5 "strings" 6 ) 7 8 func Stringify(data []interface{}) string { 9 var strs []string 10 for _, item := range data { 11 switch v := item.(type) { 12 case int: 13 strs = append(strs, fmt.Sprintf("%d", v)) 14 case bool: 15 strs = append(strs, fmt.Sprintf("%t", v)) 16 case string: 17 strs = append(strs, v) 18 default: 19 strs = append(strs, fmt.Sprintf("%v", v)) 20 } 21 } 22 return strings.Join(strs, "\n") 23 }