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
+17.1k Google Chrome : Your connection to website is encrypted with obsolete cryptography
+9.9k Golang : Edge detection with Sobel method
+18.3k Golang : Example for RSA package functions
+6.6k Golang : Humanize and Titleize functions
+31.2k Golang : bufio.NewReader.ReadLine to read file line by line
+5.9k Golang : Grab news article text and use NLP to get each paragraph's sentences
+17.4k Golang : Clone with pointer and modify value
+9.5k Golang : Detect number of active displays and the display's resolution
+12k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+9.3k Golang : Extract or copy items from map based on value
+9.8k Golang : Translate language with language package example
+21.6k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload