In order to delete a file, there is another simple function, called os.Remove, as shown in the following code:
package mainimport "os"func main() { if err := os.Remove("file.txt"); err != nil { fmt.Println("Error:", err) }}