We all have came across handling files in some way. Be it a '.txt' file or a '.dat' or even a '.go' file that we use to write our Go Programmes.
So, files are something, where we store some information.
Say for example, we want to write the below paragraph to a file.
So, we want to store the four lines in a File and name the File as 'myfirstfile.txt'.
And in general, you need to follow the below steps create the file and write the lines :
Again, if you want to make some changes to the file(Say adding or deleting a few lines) :
Similarly, if you want to delete the 'myfirstfile.txt' :
Now, let us corelate, how can we achieve the same in Go.
So, to both read and write to a file , Go provides the io/ioutil module.
Next, let us see, how can we write the above lines to a file named 'myfirstfile.txt'.