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
+16.6k Golang : How to generate QR codes?
+20.9k Golang : Create and resolve(read) symbolic links
+5.4k Golang : Shortening import identifier
+4.6k Fix Google Analytics Redundant Hostnames problem
+5.1k Golang : How to deal with configuration data?
+6.3k Golang : Combine slices of complex numbers and operation example
+5.4k Javascript : How to refresh page with JQuery ?
+10.9k Golang : Roll the dice example
+25k Golang : Get current file path of a file or executable
+5.8k PHP : How to check if an array is empty ?
+8.2k Golang : Add text to image and get OpenCV's X, Y co-ordinates example
+10.7k Golang : Sieve of Eratosthenes algorithm