Channel direction in function signatures

Use <-chan T for receive-only and chan<- T for send-only channels in Go function signatures to enforce unidirectional data flow.

Channel direction in Go function signatures is indicated by the chan keyword followed by <- to specify receive-only (<-chan T) or send-only (chan<- T) channels. Use <-chan T when a function only reads from the channel and chan<- T when it only writes to it, enforcing type safety at compile time.

// Receive-only: function reads from ch but cannot write
func consumer(ch <-chan int) {
    for n := range ch {
        println(n)
    }
}

// Send-only: function writes to ch but cannot read
func producer(ch chan<- int) {
    ch <- 42
}

// Bidirectional: function can both read and write
func handler(ch chan int) {
    ch <- 1
    n := <-ch
}