DEV Community

Discussion on: Golang Tutorial - 10 Concurrency with channel

Collapse
 
faroque_eee profile image
Md Omar Faroque
func main() {
    //create a channel
    c := make(chan <-int)

    //put a value into channel
    //wrapped inside goroutine
    go func() {
        c <- 43
    }()

    //retrieve a value from channel
    fmt.Println("value of channel c:", <-c)
}
Enter fullscreen mode Exit fullscreen mode

This code fails because channel was send only.

Collapse
 
nadirbasalamah profile image
nadirbasalamah

Thanks for your feedback, i will change it.