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
+22.5k Golang : How to read JPG(JPEG), GIF and PNG files ?
+16k Golang : Get file permission
+28.6k Golang : Change a file last modified date and time
+22.8k Golang : Set and Get HTTP request headers example
+14.1k Golang : Compress and decompress file with compress/flate example
+6.8k Golang : Derive cryptographic key from passwords with Argon2
+8.6k Golang : Add text to image and get OpenCV's X, Y co-ordinates example
+10.7k Golang : Allow Cross-Origin Resource Sharing request
+11.1k Golang : Web routing/multiplex example
+9.5k Golang : Get all countries currencies code in JSON format
+7.7k Android Studio : AlertDialog to get user attention example
+10.4k Golang : Generate random integer or float number