Solution Review: Demonstrate the Blocking Nature

This lesson discusses the solution to the challenge given in the previous lesson.

package main
import "fmt"
import "time"
func main() {
c := make(chan int)
go func() {
time.Sleep(5 * 1e9)
fmt.Println("received", <- c) // value recieved from channel
}()
fmt.Println("sending", 10)
c <- 10 // putting 10 on the channel
fmt.Println("sent", 10)
}

Get hands-on with 1200+ tech skills courses.