How can I print the contents of a channel in Go?
For example:
package main
import "fmt"
func main() {
ok := make(chan int)
ok <- 1
x := <- ok
fmt.Println(x)
}
As I understand, ok
is a channel which can store an integer value. So, how can I print its contents?
fmt.Println(ok)
doesn't print the value stored inside the channel.
Thanks.