Skip to content

Instantly share code, notes, and snippets.

@keshavab
Created June 17, 2016 08:23
Show Gist options
  • Select an option

  • Save keshavab/c12956499de7b104e8e3ffb23d87cf2d to your computer and use it in GitHub Desktop.

Select an option

Save keshavab/c12956499de7b104e8e3ffb23d87cf2d to your computer and use it in GitHub Desktop.
testing nil channel
package main
import (
"fmt"
"time"
)
func main() {
var ch chan int
go func() {
for {
select {
case ch <- 10:
fmt.Println("Send successful.")
default:
time.Sleep(1 * time.Second)
fmt.Println("Waiting ...")
}
}
}()
time.Sleep(2 * time.Second)
ch = make(chan int)
time.Sleep(4 * time.Second)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment