Skip to content

Instantly share code, notes, and snippets.

@armando-couto
Created March 7, 2022 00:15
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 armando-couto/c1823a709e163934be2a35117e65a01d to your computer and use it in GitHub Desktop.
Save armando-couto/c1823a709e163934be2a35117e65a01d to your computer and use it in GitHub Desktop.
The first question of multiple channels being ready simultaneously seems interesting. Let’s just try it and see what happens!
package main
import (
"fmt"
)
func main() {
c1 := make(chan interface{})
close(c1)
c2 := make(chan interface{})
close(c2)
var c1Count, c2Count int
for i := 1000; i >= 0; i-- {
select {
case <-c1:
c1Count++
case <-c2:
c2Count++
}
}
fmt.Printf("c1Count: %d\nc2Count: %d\n", c1Count, c2Count)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment