github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2014/research2/select.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  )
     7  
     8  func main() {
     9  	c1 := make(chan int, 1)
    10  	c2 := make(chan int, 1)
    11  	c1 <- 42
    12  
    13  	select {
    14  	case v := <-c1:
    15  		fmt.Println("received from c1: ", v)
    16  	case c2 <- 1:
    17  		fmt.Println("sent to c2")
    18  	case <-time.After(time.Second):
    19  		fmt.Println("timed out")
    20  	default:
    21  		fmt.Println("nothing ready at the moment")
    22  	}
    23  }