I have a function in Go that returns two values. I want to run this as a goroutine, but I can\'t figure out the syntax for creating a channel that receives two values. Could som
Another option would be to use an anon function like so:
package main
import "fmt"
func f(c chan func() (int, string)) {
c <- (func() (int, string) { return 0, "s" })
}
func main() {
c := make(chan func() (int, string))
go f(c)
y, z := (<-c)()
fmt.Println(y)
fmt.Println(z)
}
Credit to https://gist.github.com/slav/ca2ee333c29b8f76b557c9b10b371b52