![]() Now simply write following line to write line to file - fmt. Now we need Writer for writing line, we can create it using bufio package as writer := bufio. We will add a defer statement to close file, so that once our work is done file handle is closed, defer fileHandle.Close() You can pass relative(./file_name) or abosulte path(C:/folder_name/file_name) of file to Open method. In this post, we will see how to write to the file, we will again use bufio package.įirst create file to we wish to write to (It points to file, if it exist already) fileHandle, _ := os. We saw how easy it is to read from file in golang in my previous post here
0 Comments
Leave a Reply. |