Hello and welcome to the Go programming language course.
Implementation of client and server project by protocol buffer in this example, we want to create a
program that establishes communication between a client and a server to the port call buffer.
Therefore, our program has to pass a client port and a server part.
The client is supposed to send the information to the server in a serialized manner, and the server
will receive the data, then the serialized and display it.
Now it's time to go to this school program to create our project, client and server.
First, go to Explorer and create a project folder like named information.
And for a nation.
And create a folder inside it named Port Harcourt
Portal tool and create the fine con person with the Port Extension inside it.
Correct.
First, we define the syntax inside it and said it's value equal to proto three, which represent the
political bottom version three.
Three to three.
And now define option and set go on the score package value.
Option go on the Restore package is less cruel to cool.
They go under a school package option, defines the import parts of the package will be contain.
All the generated code for the gold package name will be the last pass component of the import pass.
Now, define political power, for example, you want to name me person message person and define two
variables first I.D. by end types, they can name by this string type, enter age by the end times.
So urine and terry to I.D. equals one.
A string name equals two and end three to four h equals three.
In order to be able to use our political class, we must first compile it when we compounded the fine
with the extension, the TV that was created inside the project, which is the equivalent of the political
party and go language and be relaxed the confidence in the political benefit through the creative distracted
by.
Now it's time to compile our political bomb for failing to create the equivalent goal and fight.
So go to the project path and try comp. Come and see the information and run the comment through to
take the test school on school out.
He calls for this nation we support thought that indicate current path and for source path.
Go to the political package and call person the product or political package and person pull it.
Now, Ron, the command.
Now we can see that the final con person thought PBE that go extension was created in the Project Pass,
which we can use to exchange our data, it's time go to the root of project and create the main fine.
So the package name and defined main function to use this protocol buffer.
May God go
package name and create main function from me in this case, first defined to function for communication
between client and server.
First, create a function for running client that name.
It's wrong.
Client saw your right phone wrong client.
And create another function for running server that named it from Server Farm from six.
We can send parameters to the program and time by the council like flag package has the ability to read
and receive be sent parameters and provides then to the program.
So in this part, we use the flag package.
Gore provides a flag package supporting base and command line flag passing.
We will use this package to implement our Example Command Line program.
The command line arguments are available in the that are to slice the flag package allows for more flexible
loved them.
In addition, there are third party packages with additional features.
The flag package contains multiple functions for passing different black types.
There are two alternatives for each flag type.
The difference is that the first one returns a pointer to a variable and the other one accepts a pointer
to the variable.
One is S3 and the other is extreme valor, which flagged the odds this weekend pass non flag arguments.
These must follow the flag arguments.
Using the flag package involves three steps.
First, define variables to capture flag values, then define the flags.
Your go application will use and finally pass the flag provided to the applications open execution.
Most of the functions within the flag package are concerned with defining flag and binding them to variables
that you have defined.
Now let's go to create the flag parameter.
First, define a variable and cunning if string function from a black package.
This thing function defines the district flag with a specified name, different value and use string.
The return value is the address of async variable that stored the value of the flag.
So first, define the variable light option call in equals cutting string function from the flag package.
Flag dart s string.
Set a name for the flag for the exemption, Adam.
Come on and set the value for the black, for the example.
Seven.
Come and sit a description of the flag for the example, if communication.
Between server and client.
So the register is in flag with a sing function now calling pass function from flag baggage.
Go to the next line.
Flag guard pass.
Pass function passes the command line, flags from Orthodox must be called after all flowers are defined
and before flags are accessed by the program.
Now, by inserting a search, we analyze the value of receive flags and decide what the program will
do.
For example, one function to car saw the light switch
on the option.
Now define chases for the switches between receive like value in this is that they want to call the
client function if the received value is client and con server function, if the received value said
a civil right case.
Client.
Calling Ron Klein function if case his client, Ron Klein.
Case server and calling center function if case is server.
From Sarah.
Now we could define the flag and switches between return values in order not to prolong the time of
decision.
We will finish it and we will continue the content in the next session.
Goodbye.