func main() { x := 4 f := func() { fmt.Println(x) } ch := make(chan func(), 1) ch <- f f2 := <-ch f2() x = 5 f2() }
test := make(chan func (int) int) go func() { f := <- test fmt.Printf("%d\n", f(10)) }() test <- func(v int) int { return v * v }