Fix

"all goroutines are asleep - deadlock!" with Channels

Fix the 'all goroutines are asleep - deadlock!' error by ensuring every channel send has a matching receive operation to prevent blocking.

The error occurs because your program has goroutines blocked on channel operations with no other goroutine to unblock them. Ensure every send has a corresponding receive and every receive has a corresponding send, or use buffered channels to decouple them.

// Example: Fix by adding a receiver for the sender
package main

import "fmt"

func main() {
    ch := make(chan int)
    
    // Sender
    go func() {
        ch <- 42
    }()
    
    // Receiver (prevents deadlock)
    fmt.Println(<-ch)
}

If you need to send multiple values or run indefinitely, ensure the receiver loop matches the sender's logic or use select with a default case to avoid blocking.