Golang : Rename file
No File I/O operations will be complete without the capability to rename file.
Renaming a file in Go is easy. This short tutorial will demonstrate how to rename a file.
renamefile.go
package main
import (
"fmt"
"os"
)
func main() {
err := os.Rename("old_file", "new_file")
if err != nil {
fmt.Println(err)
return
}
}
Reference :
See also : Golang : Delete file
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+4.4k Javascript : How to show different content with noscript?
+5.7k PHP : Convert CSV to JSON with YQL example
+10.7k Golang : ISO8601 Duration Parser example
+6.9k Golang : Muxing with Martini example
+12.2k Golang : md5 hash of a string
+7.4k Golang : How to iterate a slice without using for loop?
+30.5k Golang : How to verify uploaded file is image or allowed file types
+16.7k Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file
+15k Golang : Basic authentication with .htpasswd file
+11.7k Golang : Simple file scaning and remove virus example
+9.2k Golang : How to capture return values from goroutines?
+5.2k Linux : How to set root password in Linux Mint