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
+10k Golang : Setting variable value with ldflags
+6.9k Nginx : Password protect a directory/folder
+20.8k Golang : Convert date string to variants of time.Time type examples
+12.3k Golang : Get month name from date example
+10.4k Golang : cannot assign type int to value (type uint8) in range error
+5.3k Python : Convert(cast) string to bytes example
+13.7k Golang : Check if an integer is negative or positive
+13.6k Android Studio : Password input and reveal password example
+4.5k Java : Generate multiplication table example
+6.1k Golang : Measure execution time for a function
+9.6k Golang : Sort and reverse sort a slice of floats