September 2017
Intermediate to advanced
466 pages
9h 33m
English
In this subsection, we will show you how to rename and move a file using Go code: the Go code will be saved as rename.go. Although the same code can be used for renaming or moving directories, rename.go is only allowed to work with files.
When performing things that cannot be easily undone, such as overwriting a file, you should be extra careful and maybe inform the user that the destination file already exists in order to avoid unpleasant surprises. Although the default operation of the traditional mv(1) utility will automatically overwrite the destination file if it exists, I do not think that this is very safe. Therefore, rename.go will not overwrite destination files by default.
Read now
Unlock full access