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.9k Golang : zlib compress file example
+26.4k Golang : Connect to database (MySQL/MariaDB) server
+6.8k Golang : Number guessing game with user input verification example
+4.3k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+14.1k Chrome : ERR_INSECURE_RESPONSE and allow Chrome browser to load insecure content
+31.9k Golang : Call a function after some delay(time.Sleep and Tick)
+4.7k Facebook : How to force facebook to scrape latest URL link data?
+4.8k Golang : Missing Subversion command
+14.8k Golang : read gzipped http response
+4.9k Golang : Map within a map example