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
+52.1k Golang : How to get time in milliseconds?
+15.7k Golang : Convert date format and separator yyyy-mm-dd to dd-mm-yyyy
+22.2k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+9.4k Golang : How to check if a string with spaces in between is numeric?
+7.7k SSL : How to check if current certificate is sha1 or sha2 from command line
+7.5k Golang : How to iterate a slice without using for loop?
+11k Golang : Natural string sorting example
+27.6k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+11.6k CodeIgniter : Import Linkedin data
+13.1k Python : Convert IPv6 address to decimal and back to IPv6
+6k Cash Flow : 50 days to pay your credit card debt
+14.1k Golang : Human readable time elapsed format such as 5 days ago