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.6k Golang : Convert an executable file into []byte example
+24.1k Golang : Call function from another package
+34.2k Golang : Create x509 certificate, private and public keys
+14.7k Golang : How to get URL port?
+8.6k Golang : Generate Datamatrix barcode
+14.2k Golang : syscall.Socket example
+14k Golang : unknown escape sequence error
+9.4k Golang : How to get garbage collection data?
+14.3k Golang : Chunk split or divide a string into smaller chunk example
+5.7k Unix/Linux : How to find out the hard disk size?
+8.7k Golang : Progress bar with ∎ character