I know this is an old post, just thought to share possible work around. Idea is basically return a func that will return multiple values. I'm not sure how much performance overhead this will create and it's a little bit ugly, but works as intended.
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) } On Wednesday, October 3, 2012 at 6:04:15 AM UTC-4, Larry Clapp wrote: > > Well, true, but it doesn't really illustrate the manual destructuring you > have to do in real usage. That's a nice trick, though, I'd forgotten about > that. > > -- Larry > > > On Wednesday, October 3, 2012 12:32:35 AM UTC-4, Glenn Brown wrote: >> >> Larry, your example can be simplified as >> http://play.golang.org/p/COL68pDwOE : >> >> package main >> >> import "fmt" >> >> type Tuple []interface{} >> >> func main() { >> c := make(chan Tuple, 1) >> c <- Tuple{1, 2, "three"} >> fmt.Println(<-c...) >> >> c <- Tuple{4, "five", 6, 7.0} >> fmt.Println(<-c...) >> } >> >> --Glenn >> >> On Oct 1, 2012, at 11:36 AM, Larry Clapp <la...@theclapp.org> wrote: >> >> > Sorry to reply to myself, but I also thought of this: >> http://play.golang.org/p/n9iYer0glo >> > >> > type Tuple []interface{} >> > >> > func main() { >> > c := make(chan Tuple, 1) >> > c <- Tuple{1, 2, "three"} >> > a := <-c >> > i1 := a[0].(int) >> > i2 := a[1].(int) >> > s3 := a[2].(string) >> > fmt.Println(i1, i2, s3) >> > >> > c <- Tuple{4, "five", 6, 7.0} >> > a = <-c >> > i4 := a[0].(int) >> > s5 := a[1].(string) >> > i6 := a[2].(int) >> > f7 := a[3].(float64) >> > fmt.Println(i4, s5, i6, f7) >> > } >> >> >> >> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.