I'm wondering what the correct syntax is for calling functions with multiple return values, one (or more) of which is of type interface{}
.
A function which returns interface{}
can be called like this:
foobar, ok := myfunc().(string)
if ok { fmt.Println(foobar) }
but the following code fails with the error multiple-value foobar() in single-value context
:
func foobar()(interface{}, string) {
return "foo", "bar"
}
func main() {
a, b, ok := foobar().(string)
if ok {
fmt.Printf(a + " " + b + "
") // This line fails
}
}
So, what is the correct calling convention?