Hands-On System Programming with Go
上QQ阅读APP看书,第一时间看更新

Delete

In order to delete a file, there is another simple function, called os.Remove, as shown in the following code:

package main

import "os"

func main() {
if err := os.Remove("file.txt"); err != nil {
fmt.Println("Error:", err)
}
}