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
+14.5k Golang : Simple word wrap or line breaking example
+5.6k Javascript : How to loop over and parse JSON data?
+14.9k Golang : GUI with Qt and OpenCV to capture image from camera
+19.9k Golang : Get current URL example
+37.8k Upload multiple files with Go
+23.6k Golang : Check if element exist in map
+18k Golang : Iterate linked list example
+30.6k Golang : How to verify uploaded file is image or allowed file types
+14.5k Golang : Recombine chunked files example
+11.1k Golang : Removes punctuation or defined delimiter from the user's input
+23k Golang : untar or extract tar ball archive example
+9k Golang : On lambda, anonymous, inline functions and function literals