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
+6k Golang : Get environment variable
+6.9k Golang : Handle Palindrome string with case sensitivity and unicode
+46.9k Golang : Upload file from web browser to server
+3.7k Chrome : How to block socketloop.com links in Google SERP?
+24.2k Golang : How to read integer value from standard input ?
+14.6k Golang : How to reverse elements order in map ?
+21.6k Golang : Calculate time different
+6k Golang : A simple forex opportunities scanner
+19.4k Golang : Convert PNG transparent background image to JPG or JPEG image
+12.8k Golang : Chunk split or divide a string into smaller chunk example
+4.9k Golang : List all packages and search for certain package
+5.8k Restart Apache or Nginx web server without password prompt