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
+10.5k Golang : Create matrix with Gonum Matrix package example
+9.5k Golang : Changing a RGBA image number of channels with OpenCV
+25.3k Golang : Get current file path of a file or executable
+9.9k Golang : ffmpeg with os/exec.Command() returns non-zero status
+4.9k Javascript : How to get width and height of a div?
+15.2k Golang : Get HTTP protocol version example
+6.7k Golang : When to use make or new?
+17.1k Golang : Covert map/slice/array to JSON or XML format
+15.3k Golang : Accurate and reliable decimal calculations
+25.8k Golang : Daemonizing a simple web server process example
+51.4k Golang : Check if item is in slice/array
+10.7k Golang : Underscore string example