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
+6.8k Swift : Convert (cast) String to Double
+20.1k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+5.9k Golang : Normalize email to prevent multiple signups example
+7.7k nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
+3.9k Unix/Linux : How to pipe/save output of a command to file?
+3.5k Javascript : How to show different content with noscript?
+17.8k Golang : Get RGBA values of each image pixel
+11.3k Golang : Sort and reverse sort a slice of bytes
+3.9k Golang : Customize scanner.Scanner to treat dash as part of identifier
+4.7k Golang : Grab news article text and use NLP to get each paragraph's sentences
+16.1k Golang : delete and modify XML file content
+10.1k Golang : Find age or leap age from date of birth example