Skip to content

Instantly share code, notes, and snippets.

@wilon
Created December 27, 2017 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilon/05d3990e02b6192017858c82dc5c084c to your computer and use it in GitHub Desktop.
Save wilon/05d3990e02b6192017858c82dc5c084c to your computer and use it in GitHub Desktop.
test chan
package main
import (
"fmt"
"time"
)
func main() {
ch := make(chan int, 1)
go func() {
inV := 1
for {
ch <- inV
fmt.Println(time.Now(), "...in", inV)
time.Sleep(1000 * time.Millisecond)
inV++
}
}()
var outV int
for {
outV = <-ch
fmt.Println(time.Now(), "...out", outV)
time.Sleep(4000 * time.Millisecond)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment