Goroutines communicate with each other using channels.
We can make unbuffered channels that have no size limit of data. A memory address is allocated to act as the channel.
We can send and receive values via the channel. In goroutines, we send values to the channel. Then, retrieve the value after running goroutines.
We can make buffered channels that have a specified capacity, meaning the number of values allowed in a channel. If the buffer is not full yet, we can still send data to the buffered channel.
When multiple goroutines use the same channel, the goroutine that finishes earlier determines the received data.
A channel is stopped when it sends data. The channel will be open again when another goroutine, including the main() function, consumes the data. A channel is stopped when it receives data. The channel will be open again when another goroutine, including the main() function, sends another piece of data.
When goroutines are blocked and unable to proceed, there is a deadlock. The goroutines are waiting on each other. When a buffered channel has more receipts than transmissions, a deadlock results. When a buffered channel is full, an additional transmission results in a deadlock.
We can use "range" to loop over the elements in a channel.
Playlist of my Go language course
• Golang tutorial | Go programming language ...
Playlist of my JavaScript course
• [20 hours] JavaScript full course for begi...
Playlist of my HTML5 and CSS3 tutorials
• [12 hours] HTML and CSS full course for be...
Playlist of my algorithm walkthrough
• Algorithms and data structures | DSA cours...
Playlist of my Java course
• [14 hours] Java full course for beginners ...
Playlist of my Java examples
• Java projects for beginners | Java project...
#golang #golangtutorial #golanguage #begincodingfast #goprogramming #learnprogramming #codingtutorial