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
+10.5k Golang : Create matrix with Gonum Matrix package example
+7.4k Android Studio : How to detect camera, activate and capture example
+22.8k Golang : untar or extract tar ball archive example
+23.7k Find and replace a character in a string in Go
+7.8k Golang : Regular Expression find string example
+14.4k Golang : How to filter a map's elements for faster lookup
+5.7k Linux/Unix/PHP : Restart PHP-FPM
+11.4k Golang : Delay or limit HTTP requests example
+21.2k Golang : How to get time zone and load different time zone?
+5.2k Responsive Google Adsense
+10.7k Golang : Get currencies exchange rates example