# error: cannot close receive-only channel ch (variable of type <-chan int)

- **ID:** `go/close-of-receive-only-channel`
- **Domain:** go
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The compiler rejects close() on a receive-only channel type. This surfaces when a function signature returns <-chan T but the implementation tries to close it internally.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.22 | active | — | — |

## Workarounds

1. **** (97% success)
   ```
   func producer() <-chan int {
    ch := make(chan int)
    go func() {
        defer close(ch)
        // send...
    }()
    return ch
}
   ```
2. **** (93% success)
   ```
   func producer(done <-chan struct{}) <-chan int {
    ch := make(chan int)
    go func() {
        defer close(ch)
        select { case <-done: return; default: }
    }()
    return ch
}
   ```

## Dead Ends

- **** — Type conversion doesn't change directionality for close; the compiler still rejects it because the static type is receive-only. (90% fail)
- **** — Receivers ranging over the channel will block forever waiting for a close that never comes. (70% fail)
