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
+7k Golang : Join lines with certain suffix symbol example
+15.3k Golang : Save(pipe) HTTP response into a file
+15k Golang : Adding XML attributes to xml data or use attribute to differentiate a common tag name
+10.3k Golang : Random Rune generator
+5.8k Fix yum-complete-transaction error
+28.8k Golang : Read, Write(Create) and Delete Cookie example
+62.9k Golang : Convert HTTP Response body to string
+9.6k Golang : Accessing content anonymously with Tor
+21.7k Golang : How to read float value from standard input ?
+17.2k Golang : XML to JSON example
+12.9k Golang : Convert int(year) to time.Time type