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
+7.6k Golang : Handling Yes No Quit query input
+7.2k Golang : Gargish-English language translator
+39.2k Golang : How to iterate over a []string(array)
+7.5k Golang : Accessing dataframe-go element by row, column and name example
+5.2k Linux/Unix/MacOSX : Find out which application is listening to port 80 or use which IP version
+13.1k Golang : Get terminal width and height example
+15.4k Golang : Accurate and reliable decimal calculations
+9k Golang : Accept any number of function arguments with three dots(...)
+6.6k Unix/Linux : How to get own IP address ?
+13.7k Golang : reCAPTCHA example
+7k Golang : Calculate BMI and risk category