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
+21.6k Golang : Join arrays or slices example
+5.6k Golang : Denco multiplexer example
+10.6k PHP : Convert(cast) bigInt to string
+7.9k Golang : Qt splash screen with delay example
+8.5k Golang : Get final balance from bit coin address example
+4.4k Javascript : Access JSON data example
+7.9k Golang : Randomize letters from a string example
+14.8k Golang : How to check if IP address is in range
+10.6k Golang : Sieve of Eratosthenes algorithm
+30.1k Get client IP Address in Go
+16.1k Golang : Get IP addresses of a domain name
+6.3k Golang : Totalize or add-up an array or slice example