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.7k Golang : Shuffle strings array
+9.8k Golang : Quadratic example
+11.4k Golang : How to pipe input data to executing child process?
+19.8k Golang : Close channel after ticker stopped example
+14.6k Golang : How to shuffle elements in array or slice?
+22.9k Golang : Strings to lowercase and uppercase example
+17.4k Golang : When to use init() function?
+52.1k Golang : How to get time in milliseconds?
+18.1k Golang : Simple client server example
+15.8k Chrome : ERR_INSECURE_RESPONSE and allow Chrome browser to load insecure content
+9.5k Golang : How to get garbage collection data?
+13.8k Golang : reCAPTCHA example