Hello and welcome to the Golang programming language course in this session.
We want to talk about the others concurrency concept.
Channels.
Gore provides a mechanism called a channel that is used to share data between GO routines, a channel
as a medium through which the Gore team communicates with another gore routine.
And this communication is like free or in other wars.
A channel is a technique which allows to let one go routine to send data to another goal routine.
By default, channel is bi directional means the go routines can send or receive data through the same
channel as shown in the below image.
When you execute a concurrent activity as a go routine, a resource or data needs to be shared between
goal routines.
Channels act as a pipe between the go routines and provide a mechanism that guarantees a synchronous
exchange.
Data time need to be specified at the time of declaration of the channel.
We can share values and pointers off built in named extract reference types that are passed around on
channels.
Only one goal routine has access to a data item at any given time, so data races cannot take you.
Creating a channel.
In language at Channel is created using Chen Keyboard, and it can only transfer data of the same time
different types of data are not allowed it to transport from the same channel.
Now you can see the syntax.
You can also create the channel using make function using a shorthand declaration.
Now you can see the syntax of make function.
Now let's go to this school and bring it on to illustrate how to create the channel
first, creating a channel using that keyboard by the integer type.
So we write that name for the channel, for example, Chan and Wong
and Chen Keyboard.
By the time it's
now print value and type of defined channel FP Chan one value column and said Channel one.
Go to the next line and print channel one, type f f channel long time
per cent T often case channel long value.
Now creating a channel using make function, so define embedded above like channel to Channel two,
column equals, make function and sit churn and type is eight.
And again, print values and type of defined channel.
So copies to these lines and change these for this value to China to.
Reformat the code, save the project and execute the program, go round the package main.
That's cool.
Now we can see the output.
We could define channel via two methods first by Chan key vote and second by make function and could
see value and type off those channels in order not to prolong the time of decision.
We will finish, then we will continue the content in the next session.
Goodbye.