Hello and welcome to the golden programming language course in the previous session, we talked about
protocol for concept, and in this session it's time to go to this school program to illustrate how
to use political power.
First, go to Explorer and create a project folder like name library
line breaks.
Create a folder inside it named Harcourt.
True to call and create a find card with the Porto extension inside its bow to prove to.
First, we define the scene text inside it and said it's value equal to PER2 three, which will represent
the port call buffer version.
Syntax
equals proto three.
Now define option and sit go on the score package value.
So we write option go on underscore package equals cash flow to
go on.
The Restore package option defines the import path of the package, which will contain all the generated
code for this fine.
The gold package name will be the last pass component of the import pass.
Now define port call off.
For example, we won't name it Bauchi soul, right?
Message
board.
And define two variables first name by this string type and second Espeon by the aid type.
A strange name equals one.
And it turned to ice in equals to
in order to be able to use our vertical bar for killers.
We must first compile it.
Then we compound it.
Find with the extensions Dot PBE Dot Go is created inside the project, which is the equivalent of the
port call baffling.
Go back and we will access the components in the protocol before through the created a distraught fun
before the compound, first in a star requirements packages so bright.
City Library,
go.
Get that you Google Docs, go like dot org slash proto off first execute this command and after eat
this slash for it all.
And after Randy's comment, Rahm.
C and D slash pro to Dash Gen Dash go first in a star.
These three conference.
Before I installed them, required details were installed, now it's time to compile our political power
for fine to create the equivalent golden fine, so go to project paths and write compile command pro
talk dot.
The Dash Dash go on score out equals four destination.
We set Dart that indicate current pass and four source pass.
Go to the particle package and call book Dark Portal fine for a little code and call book Dark Portal
and execute the command.
OK, we can see that if fine, Carl Butch got that go extension was created in the Project Pass, which
we can use to exchange our data.
Now go to the root of project and create a main file and create main function to use these political
buffer, create creative phone, may the school package name and create main function for me.
First, define a variable from book history and initialize it.
For example, in Bhuj call calling equals ampersand protocol.
Are.
Bush and initialize its name, for example, go programming
language
and ESPN, for example.
One, two, three, four, five and six.
Notice that the films start with a capital letter now, then we use the martial function from or package
to serialize our port call Barford data and is stored in the data variable, which we display.
This will print our encoded data.
This function accept a port the message object as input parameter and return to values.
First, a slice of byte and second, an error value.
So define two variable light data and or data.
Comma error call an equals and calling marschall function from protocol package pro tool.
There are more shy
and sit book as per the message.
Now check error status.
Lock the FATTORE and set a message marshalling.
There were.
Now, given to this serialized encoded message, I read a political buffer, so we declare a new pointer
to the book it struck with empty fields, new blue collar equals Anderson protocol.
Not much.
Then we use the John Marshall function to DC, the encoded message stored in the data and this store
in a new book on Marshall Function, passes the white forward message in by this nice variable and places
the result in portal message.
So first, define an error variable and common marshall function from Portal package.
Go to the next line ETL equals and calling on all function from Pluto.
Pluto
got on more solid punch and sent data variable as binary data and set new book as per the message is
resolved.
Value new book.
And check your status,
lock Dot's baton and set a message for a role on marshalling that will
finally be used together, Metal Gear its name and get ESPN that provided in our generated code to retrieve
and print the fields for display Balkany value.
We can't get name gear to solve you, right FP.
Name calling.
New book Don't Get Me.
And for display book, I spin value, we can get and get a if p ESPN.
New for the ice spin,
the format to cool down, save the project, now let's go to round the project, go to terminal and
run the project, go from Dot Backer Slash Maine dot com.
Now we can see the output main go programming language and ISBN one two three four five six.
So we were able to create a protocol buffer and use it inside the main method.
First, the data were serialized using the marsh and function of the Portal package and displayed then
serialized data by the en marche en fonction from the port of package is exist, serialized or the other
words, these serialized end displays OK.
In order not to prolong the time of decision, we will finish it and we will continue the content in
the next session.
Goodbye.