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
+11.5k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard
+11.2k Golang : Print UTF-8 fonts on image example
+6.3k Golang : Transform lisp or spinal case to Pascal case example
+14.4k Golang : Force download file example
+3.8k Linux/MacOSX : Search and delete files by extension
+5.4k Golang : Process non-XML/JSON formatted ASCII text file example
+10.7k Golang : GTK Input dialog box examples
+6.3k Golang : Array mapping with Interface
+6.5k Golang : How to handle file size larger than available memory panic issue
+24.9k Golang : Get executable name behind process ID example
+5.1k CodeIgniter/PHP : Remove empty lines above RSS or ATOM xml tag