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

2016-08-12 Thread Jesse McNelis
On Sat, Aug 13, 2016 at 4:41 AM, 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). Your code below indicates that you're storing a []interface{} not an []string. > Have I overlooked something and there

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

2016-08-12 Thread Val
Looks fine to me. You'll have to iterate anyway. You can save a little perf by allocating directly the right size for your temp slice, with make. Then use indexing instead of append. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

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

2016-08-12 Thread Vasily Korytov
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 strings.Join (I need one string for output). This way works, that is explicitly creating []string and copying each element to it: var list []strin