Go is in development for v1. Interested in contributing or chatting with us?Get in touch!
Go - Bucket.File.Delete()
Delete a file from a bucket.
import (
"context"
"fmt"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
bucket, err := nitric.NewBucket("bucket-name").With(nitric.BucketDeleting)
if err != nil {
return
}
err := bucket.File("cat.png").Delete(context.TODO())
if err != nil {
return
}
if err := nitric.Run(); err != nil {
fmt.Println(err)
}
}
Parameters
- Name
ctx
- Required
- Required
- Type
- context
- Description
The context of the call, used for tracing.
Examples
Delete a file
import (
"context"
"fmt"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
bucket, err := nitric.NewBucket("bucket-name").With(nitric.BucketDeleting)
if err != nil {
return
}
contents, err := bucket.File("cat.png").Delete(context.TODO())
if err != nil {
return
}
if err := nitric.Run(); err != nil {
fmt.Println(err)
}
}