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
+6.8k Golang : How to execute code at certain day, hour and minute?
+7k Golang : Tell color name with OpenCV example
+7.2k Golang : Number guessing game with user input verification example
+9.8k Golang : Fix - does not implement sort.Interface (missing Len method)
+19.8k Golang : How to read float value from standard input ?
+4.7k Swift : Get substring with rangeOfString() function example
+10.5k Swift : Convert (cast) Float to String
+7.2k Golang : Emulate NumPy way of creating matrix example
+25.3k Golang : Find files by extension
+11.5k Golang : HTTP response JSON encoded data
+12.3k Golang : Get dimension(width and height) of image file
+6.4k Golang : Dealing with struct's private part