Golang Concepts: Nil Channels
4 min readDec 22, 2023
In Go, channels are a core feature used for communication between goroutines. Channels are meant to be used for message sharing and hence when I encountered nil channels, I started to wonder why they were needed.
What are nil channels?
A nil
channel in Go is a channel that has been declared but not initialized with a make statement, or explicitly set to nil
.
A nil channel has the following properties:
- Receiving from a nil channel blocks forever.