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
+5.6k Clean up Visual Studio For Mac installation failed disk full problem
+5k Javascript : How to get width and height of a div?
+7.6k Golang : Get YouTube playlist
+5.3k Golang : Customize scanner.Scanner to treat dash as part of identifier
+13.6k Golang : Verify token from Google Authenticator App
+25.7k Golang : Generate MD5 checksum of a file
+12.2k Golang : Save webcamera frames to video file
+6k Facebook : How to force facebook to scrape latest URL link data?
+15.6k Golang : Get all local users and print out their home directory, description and group id
+12.7k Golang : Arithmetic operation with numerical slices or arrays example
+29.7k Golang : Saving(serializing) and reading file with GOB
+30k Golang : Get and Set User-Agent examples