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
+9.5k Golang : Get UDP client IP address and differentiate clients by port number
+11.1k Golang : convert(cast) string to integer value
+22.6k Golang : Daemonizing a simple web server process example
+6k Golang : Array mapping with Interface
+3.7k Mac OSX : Get disk partitions' size, type and name
+8.5k Golang : Resumable upload to Google Drive(RESTful) example
+17.6k Golang : Calculate entire request body length during run time
+12.1k Golang : reCAPTCHA example
+28.1k Golang : Get and Set User-Agent examples
+29.6k Golang : Convert an image file to []byte
+18.4k Golang : Reset or rewind io.Reader or io.Writer
+6.1k Golang : Validate credit card example