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
+9k Golang : Find and replace data in all files recursively
+3.6k Adding Skype actions such as call and chat into web page examples
+8k Golang : How to extract video or image files from html source code
+6.1k Golang : Accessing dataframe-go element by row, column and name example
+4.7k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+25.6k Golang : How to check if a connection to database is still alive ?
+8.5k Golang : Accessing content anonymously with Tor
+7.6k Golang : Progress bar with ∎ character
+20.3k SSL : How to check if current certificate is sha1 or sha2
+14.2k Golang : Validate hostname
+12.8k Golang : convert rune to unicode hexadecimal value and back to rune character
+6.1k Golang : How to detect if a sentence ends with a punctuation?