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
+5.9k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+14.6k Golang : How to filter a map's elements for faster lookup
+11.5k Golang : Characters limiter example
+16.5k CodeIgniter/PHP : Create directory if does not exist example
+7.4k Golang : Use modern ciphers only in secure connection
+5k Unix/Linux : secure copying between servers with SCP command examples
+5.6k Golang : What is StructTag and how to get StructTag's value?
+9.2k Golang : How to use Gorilla webtoolkit context package properly
+25.4k Golang : Storing cookies in http.CookieJar example
+16.2k Golang : Read large file with bufio.Scanner cause token too long error
+13.8k Golang : Strings comparison
+6k AWS S3 : Prevent Hotlinking policy