mirror of
https://github.com/SourceFellows/gobuch.git
synced 2025-08-03 05:02:16 +02:00
initial import
This commit is contained in:
19
hello-channel-post/main.go
Normal file
19
hello-channel-post/main.go
Normal file
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func f(left, right chan int) {
|
||||
left <- 1 + <-right
|
||||
}
|
||||
|
||||
func main() {
|
||||
leftmost := make(chan int)
|
||||
var left, right chan int = nil, leftmost
|
||||
for i := 0; i < 100000; i++ {
|
||||
left, right = right, make(chan int)
|
||||
go f(left, right)
|
||||
}
|
||||
right <- 0
|
||||
x := <-leftmost
|
||||
fmt.Println(x)
|
||||
}
|
Reference in New Issue
Block a user