Golang : Delete file
Deleting file in Go is simple. This short tutorial will demonstrate how to delete a file.
Let choose a file deleteme.file
as target practice and the code example below will remove the deleteme.file
when executed.
deletefile.go
package main
import (
"fmt"
"os"
)
func main() {
err := os.Remove("deleteme.file")
if err != nil {
fmt.Println(err)
return
}
}
Reference :
See also : Golang : Rename file
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+3.2k JavaScript: Add marker function on Google Map
+4.6k Mac/Linux/Windows : Get CPU information from command line
+11.3k Golang : Check if an integer is negative or positive
+3.5k Golang *File points to a file or directory ?
+3.9k nginx : force all pages to be SSL
+7.4k Golang : Translate language with language package example
+8.3k Golang : How to determine a prime number?
+29.6k Golang : All update packages with go get command
+10.9k Golang : Fix cannot use buffer (type bytes.Buffer) as type io.Writer(Write method has pointer receiver) error
+5.1k Golang : Levenshtein distance example
+3.5k Golang : How to search a list of records or data structures
+5.4k Javascript : How to get JSON data from another website with JQuery or Ajax ?