Hello and welcome to the gold and programming language course in the previous session, we talked about
get fine information, and in this, we want to talk about the other files and directories concept.
How to read the fine.
When it comes to reading large fines, obviously we don't want loading to find in memory.
I or package in Go comes to the rescue when reading large files for these purpose.
We use the new scanner function, new scanner function, two returns and new a scanner to read from
Iowa to reader.
Now you can see the syntax.
Let's go to a school with program to illustrate how to redefine data.
First, create a term that defined in current directory.
So we create a fine name, tend to the and write some text in it, for the example.
Hello.
And welcome
to global programming.
Go to the next line language, of course, save the text file and close it.
Go to the quote.
Now the U.S from open function from all this Package two opens the main file or reading it.
Successful methods on the return file can be used for reading so first defined.
Two variables like fine comma error column equals inward open function from all start package and sets
name fine 10.
So we check the printed message for us if there is not A..
If at all.
Not equals to me.
Embody a statement of Eve, the rides launched the battle and said it will
hear views from the author for closing fine in good language, defeatist statements delayed the execution
of the function or a method or an anonymous function until the nerve a function returns so.
He writes, the FAA finds the pills after we create a fine.
The news from New Iskander function two returns in new scanner to read from eye 0.4 either.
So in this case, we pass 10 fine as I ordered reader arguement to function and get a scanner object.
So first, define a variable like this scanner column equals and invoke new scanner function from both
or package both I or don't invoke new scanner function and said fine as reader argument, so said fine.
Now we'll be go to scan their object from newest scanner function.
So use scan metal inside their scanner.
Object scan at once is the scanner to the next token, which will then be available throughout the box
or takes method if returns fonts.
Then this kind of stops either by reading the end of the input or in the own so right for scanner,
but card this can function.
And right by this statement, if he.
I text all the scans, Skinner, the text.
After scanner returns false, the air or metal will return any road that occured during a scanning exit
that if it was, I ordered it, or if you are you returning it so you check to print a message for us.
If the error is not empty, he's error calling equals scanner dot e r function, you know, not equals
need and right by a statement log dot photon at all reformat the code saved the project and execute
the program.
Now we can see the outcome.
Hello, and welcome to go programming language course.
So we were able to read the information inside the file and display it in order not to prolong the time
of decision.
We will finish it and we will continue the content in the next session.
Goodbye.