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
+9.4k Golang : Select region of interest with mouse click and crop from image
+12.6k Golang : How to check if a file is hidden?
+3.1k Golang : PGX CopyFrom to insert rows into Postgres database
+44.4k Golang : Marshal and unmarshal json.RawMessage struct example
+5.8k Golang : Fixing Gorilla mux http.FileServer() 404 problem
+4.7k Swift : Get substring with rangeOfString() function example
+7.3k Golang : Ackermann function example
+4.3k Golang : The Tao of importing package
+8.6k Javascript : Read/parse JSON data from HTTP response
+12.4k Golang : Query string with space symbol %20 in between
+12.5k Golang : Activate web camera and broadcast out base64 encoded images