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
+6.2k Unix/Linux : Use netstat to find out IP addresses served by your website server
+7.5k Golang : Convert(cast) io.Reader type to string
+12.4k Golang : Arithmetic operation with numerical slices or arrays example
+5.2k Golang : Pad file extension automagically
+48.4k Golang : Upload file from web browser to server
+21.6k Golang : Setting up/configure AWS credentials with official aws-sdk-go
+4.5k Javascript : Access JSON data example
+9.6k Golang : Qt get screen resolution and display on center example
+5.7k Golang : Markov chains to predict probability of next state example
+10.2k Golang : cannot assign type int to value (type uint8) in range error
+13.5k Golang : Activate web camera and broadcast out base64 encoded images
+3.6k Golang : Switch Redis database redis.NewClient