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
+12.6k How to automatically restart your crashed Golang server
+4.7k Unix/Linux : Get reboot history or check when was the last reboot date
+15.3k CodeIgniter/PHP : Create directory if does not exist example
+5.8k Golang : Levenshtein distance example
+4.7k Golang : Fix opencv.LoadHaarClassifierCascade The node does not represent a user object error
+10.7k Golang : Convert a rune to unicode style string \u
+34.8k Golang : Display float in 2 decimal points and rounding up or down
+4.3k Golang : Return multiple values from function
+17.4k Golang : Get host name or domain name from IP address
+27.3k Golang : Saving(serializing) and reading file with GOB
+5.1k Golang : How to solve "too many .rsrc sections" error?
+7.1k Golang : HTTP Server Example