os.Remove() function can be used to delete a folder in Golang. Below is the signature of this function
func Remove(name string) error
Code:
package main
import (
"log"
"os"
)
func main() {
err := os.Remove("sample")
if err != nil {
log.Fatal(err)
}
}
Output:
Deletes sample folder from the current working directory