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
+8.5k Golang : Another camera capture GUI application with GTK and OpenCV
+9k Golang : Get curl -I or head data from URL example
+9.9k Golang : Convert octal value to string to deal with leading zero problem
+21.6k SSL : How to check if current certificate is sha1 or sha2
+8k Golang : Variadic function arguments sanity check example
+13k Golang : Convert(cast) uintptr to string example
+12k Golang : Perform sanity checks on filename example
+5.7k Javascript : How to replace HTML inside <div>?
+9.9k Golang : Translate language with language package example
+27.3k Golang : Convert CSV data to JSON format and save to file
+9.9k Golang : Get escape characters \u form from unicode characters
+3.6k Golang : Switch Redis database redis.NewClient