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
+9k Golang : Generate random Chinese, Japanese, Korean and other runes
+9.5k Golang : List available AWS regions
+5.4k Fix fatal error: evacuation not done in time problem
+5.8k Golang : Missing Subversion command
+4.6k HTTP common errors and their meaning explained
+4.5k MariaDB/MySQL : Form select statement or search query with Chinese characters
+8.7k Golang : Populate or initialize struct with values example
+7.9k Golang : Find relative luminance or color brightness
+8k Swift : Convert (cast) Character to Integer?
+5.8k PHP : How to check if an array is empty ?
+31.2k Golang : How to convert(cast) string to IP address?
+34.7k Golang : Upload and download file to/from AWS S3