Hello and welcome to the Golang programming language course.
In the previous session, we could define the function name G.R. PC server initialize or to initialize
the DB connection field of the G.R. PC controller struct and using it in this session, it's time to
implement the Jarvis's server methods.
If you remember in our profile, we create messages and services related to G.R. PC.
Then we compiled our existing profile and created the equivalent profile in gold language.
Now it's time to implement the metals in the proto file and go blank in the JROTC series.
For this purpose, we go to define created from our compile profile.
So go to Project folder and go to a protocol folder and open a student on the RISCOS your PC that he
did not go okay.
These functions are located in the student service server interface and the open defined box by press
cards for F and type service server.
OK, now we can see two implemented functions in the port of fine carpet, these two functions and transfer
them to our G.P.S. service and implement them.
Copy these files.
And go to service controller.
One is the get a student by either method, which takes students either as a parameter and returns the
complete information of that student.
And another is they get the students by name, which receives name as the input parameter and fits all
the students whose names are equal to the input parameters.
Now go to implement this function for the jihadist control strike.
Let's start with the get the student by I.D. function, so we right fine
set a variable like server by the time GOPAC controller as implements the function server
and asterisk G.R. PC controller.
Get a student by idea and set a variable for context like context.
And set the value of a light idea to point the search by item message from protocol package IED.
And sits asterisk.
And that particular.
Oh, it's huge.
Why?
And set return times first is teasing this strike from political package that created in GOP support
to fine.
Asterisk, plural, to quote art students and said their hopes, their method was created.
Now we have to implement its body by calling the server object from the GOP controller a strong.
It has access to the DB connection field through which we can con the get a student by either the method
that accept an I.D. as input parameter and return to values.
First, the student information whose IDE is equal to the input from the third and second values.
And therefore so we defined two variables like a student
and error column equals set server, object server and call DB connection object, DB connection object.
And it will give the student based ID get the student base, i.e. the function and can't get I.D. function
from the service by either message.
By calling either variable i.e. did get idea kick error status if they're not equals, nil
return mean and error
and return values for this function student.
And need.
But we see that our method has an error and does not accept this student and return value.
The answer is all of us.
The reason for the error is that the return value of the select a student base I deem at all is a student
of the model package.
But the return value of the gift a student by either method is a student from the portal to PHI.
So we have to create the function to convert a model, a student to a pro to find a student.
So we write.
Fonts
convert to G PC.
The student sit a student from model package as input parameter.
A student
from model package model the student.
And sit a student as return tie from Portrait of My Soul, right, asterisk protocol.
The arts students
now return as student objects from protocol package and initialize it by the student values from model
pichay silver right, return ampersand protocol.
A student and initialize the field of this I.D. equals the student ID and name equals student's name
and age equals the student, but each reformat the code and saved the project.
So we were able to create the function to get an instance a student of the model package and convert
it to a student of p0.05.
Now go to the get a student by either method and use this function for convert the student instance.
So clear the error code.
And return Colin Koehler to jobs student function and set a student as input parameter for converter
protocol as students convert to a job as a student and sit as a student and sit near, reformat the
code and save the project and we don't have any or OK now we could implement get a student by either
method, which receives an idea as the input parameter and returns the student who has that idea.
In order not to prolong the time of decision, we will finish it and we will continue the content in
the next session.
Goodbye.