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
+3.4k Golang : Shortening import identifier
+8.6k Golang : List running EC2 instances and descriptions
+13.2k Golang : Get current URL example
+4.7k Golang : A simple forex opportunities scanner
+4.8k Golang : Levenshtein distance example
+9.3k Elastic Search : Return all records (higher than default 10)
+9.6k Golang : Image to ASCII art example
+16.1k Golang : Convert date string to variants of time.Time type examples
+4.6k Golang : Null and nil value
+7.5k Golang : Find age or leap age from date of birth example
+21.1k Golang : Converting a negative number to positive number