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
+23.9k Golang : Convert uint value to string type
+2k Golang : Fix go-cron set time not working issue
+11.8k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+5.9k Mac OSX : Find large files by size
+34.2k Golang : Validate IP address
+37.7k Golang : How to read CSV file
+2.7k Java : Get FX sentiment from website example
+6.8k Javascript : Put image into Chrome browser's console
+19.7k Golang : How to read float value from standard input ?
+15.7k Golang : Find file size(disk usage) with filepath.Walk
+8.2k Golang : Scramble and unscramble text message by randomly replacing words
+18.8k Golang : Read directory content with os.Open