Channels Internals
Learn about the hchan struct and some deep concepts in Golang.
We'll cover the following...
We'll cover the following...
The hchan struct
Internally, the channels implement an hchan struct, which holds the information related to the channels. It includes the buffer size buf, the sender sendx, the receiver recvx, the channel blocked due to sending sendq, the channel blocked due to receiving recvq, the mutex lock, and many more fields.
Terminology
Let’s explore the terminology of the hchan struct.
buf: This represents the circular queue that stores the data.closed: