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.3k Golang : Convert Unix timestamp to UTC timestamp
+21.7k Golang : Calculate time different
+37.7k Golang : Convert to io.ReadSeeker type
+11.1k Golang : List running EC2 instances and descriptions
+7.7k Golang : Set or add headers for many or different handlers
+10.8k Golang : md5 hash of a string
+19.7k Golang : Create and resolve(read) symbolic links
+5.7k Golang : Derive cryptographic key from passwords with Argon2
+10.6k Golang : Find and draw contours with OpenCV example
+12.4k Golang : Strings comparison
+7.1k Golang : Add build version and other information in executables
+17.8k Golang : convert int to string