How to delete a file in go

Oct 2, 2018 22:43 · 37 words · 1 minute read

The os package has os.Remove function, which is used to delete a file as shown below.

package main

import (
    "fmt"
    "os"
)

func main() {
    err := os.Remove("test.txt")
    if err != nil {
        fmt.Println(err)
    }
}