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
+19k Golang : Check if directory exist and create if does not exist
+7.7k Setting $GOPATH environment variable for Unix/Linux and Windows
+8.9k Golang : How to use Gorilla webtoolkit context package properly
+30.4k Golang : Remove characters from string example
+9.3k Golang : Extract or copy items from map based on value
+7.7k Golang : Trim everything onward after a word
+27.2k Golang : Convert CSV data to JSON format and save to file
+8.8k Golang : Inject/embed Javascript before sending out to browser example
+5.5k Fix fatal error: evacuation not done in time problem
+21.5k SSL : How to check if current certificate is sha1 or sha2
+19.9k Golang : Compare floating-point numbers
+5.4k PHP : Convert string to timestamp or datestamp before storing to database(MariaDB/MySQL)