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
+13.1k Android Studio : Password input and reveal password example
+9.6k Golang : Function wrapper that takes arguments and return result example
+7.1k Golang : Process json data with Jason package
+7.6k Golang : Regular Expression find string example
+13.2k Facebook PHP getUser() returns 0
+5.7k Golang : Generate multiplication table from an integer example
+8.1k Golang : Count leading or ending zeros(any item of interest) example
+15.7k Golang : Generate universally unique identifier(UUID) example
+15.6k Golang : Read a file line by line
+13.4k Golang : Tutorial on loading GOB and PEM files
+5.9k Golang : Extract XML attribute data with attr field tag example
+20.2k Nginx + FastCGI + Go Setup.