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
+43.6k Golang : Get hardware information such as disk, memory and CPU usage
+10.7k Golang : Get local time and equivalent time in different time zone
+8k Golang : Sort words with first uppercase letter
+8.8k Yum Error: no such table: packages
+11.1k Golang : Generate random elements without repetition or duplicate
+11.3k Golang : Fix - does not implement sort.Interface (missing Len method)
+47.8k Golang : Convert int to byte array([]byte)
+23.5k Golang : Get ASCII code from a key press(cross-platform) example
+15.6k Golang : Convert date format and separator yyyy-mm-dd to dd-mm-yyyy
+14.3k Golang : Simple word wrap or line breaking example
+7.9k Golang : Gomobile init produce "iphoneos" cannot be located error
+7.1k Nginx : How to block user agent ?