Hello and welcome to the Gold Lounge programming language course in the pit of your session.
We were able to complete the package related to a PC controller and in this session we want to go to
create the main package.
So we'll go to the Project Explorer, create a new folder named name and create a new file like made
that will
now set Package Main.
First, define two function for communication between client and server.
First, create a function for running client that enabled it, for example, around your PC client.
So right from wrong.
Do your PC clients.
And create another function for running server that we named it, for example, Rongji, our PC server
farms.
Ron, G.R., PC, sir.
Before we want to use Ron G.R. PCs service, we need to create a connection to the database.
Previously, we designed the method called G.R. PC Server Initialize or in the server package.
It contains a method called connect from the DV Tools package, which by taking two values of driver
name and data source name, creates a connection to the MySQL database.
The answer previous, is save driver name and data source name information inside the JSON find in the
configuration package.
Now you can see it now it's time to use the information in our JSON file to connect to the database
for using the JSON, find the calling open function from OS Paquet that opens the named file for reading.
If successful methods on the return file can be used for reading this function, accept foreign passes,
input parameter and returns to values.
First, no object from file and the other an object from error.
So first, go to the main file and create a main function for me.
Now we defined two variables named Fong and Error for cutting the open function for almost four decades.
Five Rule call equals cutting open function from voice package.
And said, Jason, final pass as input parameter as string type can, the creation is less config dot.
Jason first check error tools if error not equals need
like dot matter and all
that off.
We use DFA for closing the created file object, so we write Ether.
Find close.
Now, create this right on top of the main menu that contains valuable equivalent to the keys in the
Jason fine that are used to map those keys to their data types and go land.
So defining a site like name configuration
type,
can he Grecian?
Let's try
try.
Their name and type is extreme string and using Jason.
Thank you, Jason.
Colin sit name.
Drive her name and go to the next line and define another key data, source name and type is history
using Jason.
Thank you, Jason.
Colin and set name data source name.
Now define an object from configuration extract.
So define a variable like that comes from configuration extract.
Equals
functionaries
now using the new decoder, a function of the Jason package, we send the Jason fine to eat as a parameter
after opening it and through the Decode Metal and reads the next J.
Some encoded value from its input and is stored in the value pointed to object created from the configuration
is.
So go to the main function and after defer find.
Be right.
Jason Dot.
Neil Decoder.
And set fire as parameter dot and decode Anderson.
This allowed us to absorb the values inside the JASON find in the variables in the configuration is
trust.
We can send parameters to the program at wrong time by the console.
Lying flat package has the ability to read and receive decent parameters and provides them to the program.
So in this part, we use the flag package.
Google provides a flag package supporting basic command line flag, passing the use this package to
implement our Example Command Line program.
If you remember in the topic of protocol author, we fully explained how to use the flag package.
Now let's go to create the flag parameter.
First, define a variable and calling a string function from the flag package.
Assign function defines the assigned flag with a specified name, default value and use a string.
The return value is the address of this string variable that distorts the value of the flag.
First, define the variable light option.
Colin equals cutting string function from the flag by his flag
dart string.
Set a name for the flag, for example, at me
and set a value for the flag.
For example, a server
and set a description of the flag for the example, a communication
between server and client.
Some of the register estimated flag with a string function now calling pass function from flag package
flag to art pass.
Pass Fonctionnent passes the common line flag from Ozarks must be called after all flags are defined
and before flags are accessed by the program.
Now, by inserting a search, we analyzed the value of recent flags and decide what the program will
do.
For example, what function to call soul.
We switch
on the option
defined cases for the search between received flag value, and this is the way you want to call decline
function.
If the received value is client in concert or function, if the received value server so bride case
clients
calling RON function if Casey's client Ron Deoxy client and case.
Sir.
And calling several function of cases, server from geographies, etc. now we could define a flag and
searches between return values.
Now right client and server function, in order not to prolong the time of decision, we will finish
it and we will continue the content in the next session.
Goodbye.