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.6k Golang : Detect sample rate, channels or latency with PortAudio
+8.3k Golang : Qt splash screen with delay example
+13.7k Golang : Tutorial on loading GOB and PEM files
+11.9k Golang : convert(cast) float to string
+32.6k Golang : Copy directory - including sub-directories and files
+24.1k Golang : Find biggest/largest number in array
+8.1k Golang : Sort words with first uppercase letter
+29.6k Golang : Saving(serializing) and reading file with GOB
+4.8k JavaScript: Add marker function on Google Map
+10.2k Golang : Edge detection with Sobel method
+9.5k Golang : Create unique title slugs example
+26.7k Golang : Encrypt and decrypt data with AES crypto