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
+6.6k Golang : Simple File Server
+3.4k Golang : Add text to image and get OpenCV's X, Y co-ordinates example
+6.3k CodeIgniter : Load different view for mobile devices
+16.4k Golang : How to verify uploaded file is image or allowed file types
+2.5k PHP : Convert CSV to JSON with YQL example
+18k Golang : How to create new XML file ?
+6.2k Golang : Overwrite previous output with count down timer
+3.6k Golang : Convert word to its plural form example
+2.5k Golang : Measure execution time for a function
+1.1k Golang : How to detect if a sentence ends with a punctuation?
+5k Golang : How to delete element(data) from map ?
+9.7k Golang : Read binary file into memory