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
+17.1k Golang : Get future or past hours, minutes or seconds
+4.4k JavaScript : Rounding number to decimal formats to display currency
+11.4k Golang : Calculations using complex numbers example
+6.3k Golang : Calculate diameter, circumference, area, sphere surface and volume
+23.3k Golang : Check if element exist in map
+7.7k Golang : What fmt.Println() can do and println() cannot do
+36k Golang : Converting a negative number to positive number
+7.9k Golang : Append and add item in slice
+10.3k Golang : Create matrix with Gonum Matrix package example
+9.6k Golang : Resumable upload to Google Drive(RESTful) example
+5.1k Javascript : Change page title to get viewer attention
+9.7k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral