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.1k Apt-get to install and uninstall Golang
+14.2k Golang : Parsing or breaking down URL
+6.8k Golang : Levenshtein distance example
+7.4k Golang : Convert(cast) io.Reader type to string
+14.1k Golang : Recombine chunked files example
+5.5k Unix/Linux/MacOSx : Get local IP address
+11.4k Golang : Convert(cast) float to int
+9.6k Golang : Get current, epoch time and display by year, month and day
+39.8k Golang : Convert to io.ReadSeeker type
+6.9k Golang : Validate credit card example
+11.5k Golang : Verify Linux user password again before executing a program example