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.


 package main

 import (

 func main() {



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.