Channels Golang | Simple Example of Buffered Channel in Golang | Golang Tutorial

preview_player
Показать описание
Simple Example to Demonstrate the use of Buffered Channel in Go Program.

What is Channel in Go:
Go provides a mechanism called a channel that is used to share data between goroutines. When you execute a concurrent activity as a goroutine a resource or data needs to be shared between goroutines, channels act as a conduit(pipe) between the goroutines and provide a mechanism that guarantees a synchronous exchange.
There are two types of Channels Buffered Channel and Unbuffered Channel.
In this video we have an example program for using Buffered Channel in Go.

Buffered Channel : In buffered channel there is a capacity to hold one or more values before they're received. In this types of channels don't force goroutines to be ready at the same instant to perform sends and receives. There are also different conditions for when a send or receive does block. A receive will block only if there's no value in the channel to receive. A send will block only if there's no available buffer to place the value being sent.

Syntax for Buffered Channel:
goroutine1 := make(chan string, 5) // Buffered channel of strings.

#golang #channelsGolang #BufferedChannelsGolang #GolangChannels #goChannels #golangExample #GolangProgram
Рекомендации по теме
Комментарии
Автор

could have just been a gist with comments

syndrome
visit shbcf.ru