This following example is straightforward, and it demonstrates how to delete a file. The standard package provides os.Remove(), which expects a file path:
package main import ( "log" "os" ) func main() { err := os.Remove("test.txt") if err != nil { log.Fatal(err) } }