package main

import (
	"context"
	"fmt"
	"log"

	"github.com/minio/minio-go/v7"
	"github.com/minio/minio-go/v7/pkg/credentials"
)

func main() {
	minioClient, err := minio.New("135.181.2.237:9000", &minio.Options{
		Creds:        credentials.NewStaticV4("admin", "lsE6TAihW98iaXKDWG+6gGLYAFdyp2iC", ""),
		Secure:       false,
		BucketLookup: minio.BucketLookupPath,
	})
	if err != nil {
		log.Fatalf("Error: %v", err)
	}

	ctx := context.Background()
	var count int64
	opts := minio.ListObjectsOptions{Recursive: true}
	for obj := range minioClient.ListObjects(ctx, "vcard-usite", opts) {
		if obj.Err != nil {
			log.Fatalf("Error: %v", obj.Err)
		}
		count++
		if count%500 == 0 {
			fmt.Printf("MinIO: %d objetos...\n", count)
		}
	}
	fmt.Printf("\nTotal en MinIO: %d objetos\n", count)
}
