Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Delete All the objects in the bucket
package main
import (
func main() {
accessKey := "accessKey"
secretKey := "secretKey"
url := "url"
myBucket := "minio-bucket1"
s3Client, err := minio.NewV2(url, accessKey, secretKey, true)
if err != nil {
// Create a done channel to control 'ListObjects' go routine.
doneCh := make(chan struct{})
// Indicate to our routine to exit cleanly upon return.
defer close(doneCh)
var arr []minio.ObjectInfo
// List all objects from a bucket-name with a matching prefix.
for object := range s3Client.ListObjects(myBucket, "", false, doneCh) {
if object.Err != nil {
arr = append(arr, object)
for j, _ := range arr {
go func(j int) {
err = s3Client.RemoveObject(myBucket, arr[j].Key)
if err != nil {
log.Println("Success", arr[j].Key)
} (j)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.