[go-nuts] Re: Cast interface{} to []string

2016-08-14 Thread 'simon place' via golang-nuts
could something like this help; https://play.golang.org/p/9tbiUY1w0d On Friday, 12 August 2016 19:41:26 UTC+1, Vasily Korytov wrote: > > Hi, > > I have an interface{} variable that can be either string or a list of > string (yes, that's bad design, I know). > > I need a []string to feed it to st

[go-nuts] Re: Cast interface{} to []string

2016-08-12 Thread Nate Finch
beware that mail.([]interface{}) will *panic* if what is in there is not a []interface{}. You should almost always use ", ok" form of type casting, i.e. list, ok := mail.([]interface{}) if !ok { // return an error or something sane } // use list On Friday, August 12, 2016 at 2:41:26 PM UTC