Hello and welcome to the Golang programming language course.
In the previous session, we talked about how to delete or remove the file and the folder go language.
And in this session, we want to talk about the other files and directories concept.
Remove all directories and files and go land in gold language, you are allowed to remove all the directory
that finds from a directory or folder with the help of remove all function.
This function removes all the directories and files from the path you will pass to this function.
It will remove everything from the specified path, but returns the first error it encounters.
If the specified path does not exist, then this method returns nil.
If this function throws an error, then it will be off time parser.
Now you can see the syntax.
It is defined under the OS package, so you have to import Always Package in your program for accessing
remove all function.
Let's go to this school program to illustrate how to remove all folders and files from the default directory.
First, we create a folder named Sample.
And Create who finds inside it named Test one test and test to that the.
Test one that takes the.
And test tube got.
And they create a folder named 10 one in sample directory.
Sample learning to through a folder and.
And then inside tent one, create another finds like Test 3.6, dentist 4.60.
Tist 3.60.
And in turn, will create another fine test for the.
OK.
The files and folders are created.
Now let's go to main function to remove the created all files and folders.
Remove all function, get the car and pass as argument and remove the files and folders.
If there is an error, it will be a time pass.
So first, define a variable like you are calling equals and can't remove all functions from oils.
Package or start streaming.
On Fawcett, the current pass, right click on the folder created named in the Explorer and select reveal
in the File Explorer and copy the current pass from address, bar and poutine here and append the folder
name end of this pass.
So right click.
Revenue in File Explorer and kupuna
and set as argument for gaming
sit dormant backslash, though, either make a splash.
Over breakfast, lunch and over breakfast, lunch and silver make a splash.
OK.
The project name is finds directories,
fonts, dash directories,
backslash, backslash and Santa folder.
OK, now we check the printed message if the error is not empty.
If you are not equal to me.
So print a message.
Large print and.
And said the error message.
OK, now go to the dash directories, pass and see files and folders, so we use on the air, come in
and see sample folder, go to the sample, see the sample and again during our week Test 1.60 test to
the test and 10 one folder, go to the tampon folder.
See 10 one folder.
And again, we are and we can see Test 3.6 and test for the next week.
We go to the car and pass.
We gave see the CD, its science and save the project and execute the program by the car and go wrong
the main that could.
Now we can see the output.
First, we created files and folders inside each other in content past and then using the removal function
from the OS package, and we were able to delete all the created files and folders.
Again, we go to find that directories passed by the comma in the air and we see it on files and folders
and deleted from here in order not to prolong the time of decision.
We will finish it and we will continue the content in the next session.
Goodbye.