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.9k Fontello : How to load and use fonts?
+14.4k Golang : Overwrite previous output with count down timer
+8k Golang : Routes multiplexer routing example with regular expression control
+28.4k Get file path of temporary file in Go
+9.6k Random number generation with crypto/rand in Go
+4.5k Golang : How to pass data between controllers with JSON Web Token
+8.8k Golang : automatically figure out array length(size) with three dots
+12k Golang : convert(cast) string to integer value
+7.1k Golang : How to fix html/template : "somefile" is undefined error?
+9.6k Golang : Turn string or text file into slice example
+16.8k Golang : How to save log messages to file?
+13k Golang : How to get a user home directory path?