Go : Delete a file or directory

This article explains how to 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)
}

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

Comments

Be the first to comment!