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
+5.4k Fix yum-complete-transaction error
+12.9k Golang : Date and Time formatting
+6.9k Golang : Null and nil value
+11.4k Golang : Verify Linux user password again before executing a program example
+20.6k Golang : How to force compile or remove object files first before rebuild?
+6.6k Golang : How to setup a disk space used monitoring service with Telegram bot
+29.1k Golang : Login(Authenticate) with Facebook example
+16.5k Golang : How to generate QR codes?
+12.6k Golang : Convert IPv4 address to packed 32-bit binary format
+15.3k Golang : Get current time from the Internet time server(ntp) example
+4.6k JQuery : Calling a function inside Jquery(document) block
+9.3k Golang : interface - when and where to use examples