Following is the code;
package main
import "fmt"
func main() {
func1(1)
}
func func1(n int) {
ch := make(chan int)
ch <- 1
for i := range ch {
fmt.Println(i)
fmt.Println(<-ch)
}
}
When I try to execute this code, it throws the following error;
fatal error: all goroutines are asleep - deadlock!
goroutine 1 [chan send]:
main.func1(0x1, 0x432070)
/tmp/sandbox451742015/main.go:11 +0x60
main.main()
/tmp/sandbox451742015/main.go:6 +0x20