You can use type assertions or reflection work with the generic interface{}
to an underlying type. How you do this depends on your particular use case. If you can expect the interface{}
to be a []interface{}
as in your example, you can:
if sl, ok := thing.([]interface{}); ok {
for _, val := range sl {
fmt.Println(val)
// Or if needed, coerce val to its underlying type, e.g. strVal := val.(string)
}
}
(Playground link)
If you can't make assumptions about the underlying type, you'll need to do some black magic using reflect
.