Go: Delete a file or directory

Use the os.Remove function to remove a file or directory:

if err := os.Remove("/path/to/file"); err != nil {	
	fmt.Println(err)
}
remove /path/to/file: No such file or directory

The error, if any, will be of type *os.PathError.

Comments