ToStringNSlice converts an interface to string in a quick way or to a slice with strings if the input is a slice of interfaces.
(data interface{})
| 81 | // ToStringNSlice converts an interface to string in a quick way or to a slice with strings |
| 82 | // if the input is a slice of interfaces. |
| 83 | func ToStringNSlice(data interface{}) interface{} { |
| 84 | switch s := data.(type) { |
| 85 | case []interface{}: |
| 86 | var a []string |
| 87 | for _, v := range s { |
| 88 | a = append(a, ToString(v)) |
| 89 | } |
| 90 | return a |
| 91 | default: |
| 92 | return ToString(data) |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | func ToHexOrString(data interface{}) string { |
| 97 | switch s := data.(type) { |
nothing calls this directly
no test coverage detected