

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 6
click for more info
Not enough gems
Cost: 6 gems
1: Concurrency
incomplete
2: Channels
incomplete
3: Channels
incomplete
4: Buffered Channels
incomplete
5: Closing Channels in Go
incomplete
6: Range
incomplete
7: Select
incomplete
8: Select Default Case
incomplete
9: Channels Review
incomplete
10: Ping Pong
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Here are a few extra things you should understand about channels from Dave Cheney's awesome article.
var s []int // s is nil
var c chan string // c is nil
var s = make([]int, 5) // s is initialized and not nil
var c = make(chan int) // c is initialized and not nil
var c chan string // c is nil
c <- "let's get started" // blocks
var c chan string // c is nil
fmt.Println(<-c) // blocks
var c = make(chan int, 100)
close(c)
c <- 1 // panic: send on closed channel
var c = make(chan int, 100)
close(c)
fmt.Println(<-c) // 0
Any buffered values are received first. Once the buffer is empty, receives return the zero value.