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.3k Golang : Parsing or breaking down URL
+10.6k Golang : Setup API server or gateway with Caddy and http.ListenAndServe() function example
+10.8k Golang : Save webcamera frames to video file
+4.8k Unix/Linux : How to open tar.gz file ?
+7.3k Android Studio : Import third-party library or package into Gradle Scripts
+32.5k Golang : Call a function after some delay(time.Sleep and Tick)
+7.4k PHP : How to parse ElasticSearch JSON ?
+14.5k Golang : How to reverse elements order in map ?
+17.7k Golang : Delete duplicate items from a slice/array
+4.5k How to check with curl if my website or the asset is gzipped ?
+7.3k Golang : How to check variable or object type during runtime?