Hello and welcome to the Golang programming language course.
In the previous session, we talked about creating a directory of folder and indecision.
We want to talk about the other files and directories concept.
Rename, file or folder.
Renamed function can be used to rename a file or folder renal function, renamed or moves all past to
new purpose.
If Neopets already exist and is not a directory, rename replaces it.
OS specific restrictions may apply.
Then old past and new paths are different directories.
Now you can see the syntax all past and new paths can be fully qualified as the.
If the old and new path doesn't lie in the same directory, then rename function behaves the same as
moving a file or folder.
Now let's go to this school program to illustrate how to rename, file or folder and go like.
First, create the fine name test in current directory, so we define two variables life by an error
call equals E will create function from always package s that create function and set a name for five
tiers.
The 60.
Now we could create a fine and current directory named Tess, and we assign returned values to two variables
like find and or so we check to print the message for us if the error is not empty row not equals need.
We use the federal function of the law kids love at FATTORE and set it all.
And then we display a like message for fun, large dance, print and set time.
And in the end of the code, we close the fun, find close, reformat the call, save the project and
execute the program.
Now you can see that the test that defined created in current directory and paint a large message.
You can go to current directory passed by the command, the air and we see the test, the the fine.
OK, now we want to use rename function for change name off fine.
In this case, we want to change fine them to 10th name.
So go to the code.
Define a variable like arrow equals endocrine function from always.
Packages will start rename first set.
Oh, fine.
In this case, this test dog takes the corner and sets a name for new fine, for the example turned
out to.
Now we check the print, a message for us, if the error is not into is the rule not equals need.
We use the fatal function of the large package, large dots that are set out or reformat the code,
save the project and execute the program.
Now we can see the name of text, the text changed to 10th and fine like message printed so we can go
to current directory passed by the Air Command.
And we can see the test that the file has changed to 10 dot so we could use from rename function to
change a file name.
Now let's rename a folder together first.
Clear the last code.
Say the project and it's ready to right first, create a folder or directory at the current pass by
the end Kar di R function define a variable like error calling equals invoke encode di R function from
all.
This package will start in K D, R R and set a folder name like 10
and set permission zero seven five.
By now, we could create a directory, a common past name temp, and we assign return value to a variable
like ETL.
Now we take the print a message for us.
If the error is not empty, e error not equals name be used from the federal function of long package
large docs, fatty acids or reformat the code, save the project and execute the program.
Now we can see the ten folder created, and we can go to the current directory passed by the comment,
the air and we see Tan folder created here.
OK, now we use rename function for change and name of directory.
In this case, we want to change tan name to new folder.
So first clear, the last code define a variable like error calling it equals invoke, rename function
or worse.
Package Voice got renamed and set all directory name.
In this case, it is tan and set a name for new folder like new folder.
OK, check to print a message for us if the error is not only if error not equals to mean we use the
federal function of like package, log the button and sit there or reformat the court, save the project
and execute the program.
Now we can see the Tan folder has changed to new folder me and we can go to the current directory passed
by the Air Command and we can see Tan Folder has changed to new folder in order not to prolong.
The time of this session will finished and we will continue the content in the next session.
Goodbye.