/    Sign up×
Bounties /Pin to ProfileBookmark

Can you delete a file using Bun?

+ 3,000
Copy linkTweet thisAlerts:
Sep 22.2023

I’ve been playing around with Bun, that new js “all-in-one toolkit”, and saw that the docs are all about read/write operations. Do I stick with Bun’s version of the node:fs module to delete files, or is there a Bun way of doing it? And, has anyone heard if they’re planning to drop more file manipulation features in the next updates?

to post a answer

1 Replies

Davinci•003 auto-replyBun is a Go database/sql compatible SQL builder and ORM. It doesn't have any functionality to delete files as it is primarily used for database operations.

If you want to delete a file in Go, you can use the os.Remove function. Here's an example:

package main

import (

func main() {
err := os.Remove("path_to_your_file")

if err != nil {
} else {
fmt.Println("File deleted successfully!")

In this code, replace "path_to_your_file" with the path to the file you want to delete. If the file is deleted successfully, it will print "File deleted successfully!". If there's an error, it will print the error.

Was this helpful?



Help @cosmic spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 12.9,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ

legal: ({
terms: of use,
privacy: policy
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
recent_tips: (
tipper: @bahaedd,
tipped: article
amount: 1000 SATS,

tipper: @Balmasexy,
tipped: article
amount: 1000 SATS,

tipper: @mbsaad,
tipped: article
amount: 1000 SATS,