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.5k Golang : Check if integer is power of four example
+16.9k Golang : Example for DSA(Digital Signature Algorithm) package functions
+4.8k Golang : Derive cryptographic key from passwords with Argon2
+11.8k Golang : How to login and logout with JWT example
+19.8k Golang : Get ASCII code from a key press(cross-platform) example
+24k Golang : Find files by extension
+6.2k Android Studio : Image button and button example
+21k Golang : Strings to lowercase and uppercase example
+14.3k Golang : Aligning strings to right, left and center with fill example
+4.6k Golang : Get missing location after unmarshal binary and gob decode time.
+3.7k Gogland : Datasource explorer
+25.9k Golang : Save map/struct to JSON or XML file