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
+7.4k Golang : Get today's weekday name and calculate target day distance example
+4.2k Javascript : Detect when console is activated and do something about it
+18.3k Golang : convert int to string
+11.4k Golang : Convert(cast) bigint to string
+11.2k Golang : Display a text file line by line with line number example
+5.4k Golang : Fix opencv.LoadHaarClassifierCascade The node does not represent a user object error
+6.9k Golang : Dealing with postal or zip code example
+12.5k Golang : Convert IPv4 address to packed 32-bit binary format
+20.2k Golang : Saving private and public key to files
+19.3k Golang : Count JSON objects and convert to slice/array
+15.1k Golang : How to convert(cast) IP address to string?
+12.8k Golang : Convert(cast) int to int64