Delete a directory in Go
A simple tutorial on how to delete a directory in Go. This tutorial is a respond to this solution which is not the recommended way.
removedir.go
package main
import (
"os"
)
func main() {
os.Remove("./TestDir")
}
To remove all the subdirectories under the target directory, replace os.Remove()
to os.RemoveAll()
Reference :
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
+46.7k Golang : Encode image to base64 example
+29.3k Golang : Get first few and last few characters from string
+13.8k Golang : Query string with space symbol %20 in between
+27.7k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+11.1k Golang : Create Temporary File
+36.4k Golang : Integer is between a range
+7k Golang : Muxing with Martini example
+14.5k Golang : Simple word wrap or line breaking example
+18.7k Golang : Logging with logrus
+19.6k Golang : Fix cannot download, $GOPATH not set error
+10k Golang : Resumable upload to Google Drive(RESTful) example
+7k Golang : Decode XML data from RSS feed