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
+9.5k Golang : Sort and reverse sort a slice of floats
+6.9k Golang : Find the shortest line of text example
+5k Golang : Check if a word is countable or not
+8.1k Golang : Emulate NumPy way of creating matrix example
+30.2k Golang : How to redirect to new page with net/http?
+16.7k Golang : How to generate QR codes?
+8.3k Golang : How to check if input string is a word?
+5.9k PHP : How to check if an array is empty ?
+12k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+10.8k Golang : Replace a parameter's value inside a configuration file example
+7.1k CloudFlare : Another way to get visitor's real IP address