Golang : Rename directory
Just a slight variation from the tutorial on moving file to another with Golang. This tutorial will show you how to rename a directory with Go.
There you go :
package main
import (
"fmt"
"os"
)
func main() {
err := os.Rename("FolderA", "FolderB") // rename directory
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
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
+13.9k Golang : Reset buffer example
+14.9k Golang : invalid character ',' looking for beginning of value
+6.6k Golang : Fixing Gorilla mux http.FileServer() 404 problem
+17.1k Golang : Upload/Receive file progress indicator
+10k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
+17k Golang : How to make a file read only and set it to writable again?
+7k Android Studio : AlertDialog to get user attention example
+7.7k Golang : Find relative luminance or color brightness
+19.3k Swift : Convert (cast) Int to int32 or Uint32
+8.3k Golang : Sort lines of text example
+7.7k Golang : Metaprogramming example of wrapping a function
+23k Golang : Check if element exist in map