package minio import ( "context" "errors" "fmt" min "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func Init(cfg Config) (*Client, error) { if err := cfg.validate(); err != nil { return nil, err } fmt.Println("cfg", cfg) client, err := min.New(cfg.Endpoint, &min.Options{ Creds: credentials.NewStaticV4(cfg.AccessKey, cfg.SecretKey, ""), Secure: cfg.UseSSL, Region: "ap-southeast-1", }) // return if error if err != nil { return nil, err } // health check if client.IsOffline() { return nil, errors.New("minio is currently offline") } fmt.Printf("⚡️[minio]: connected to %s \n", cfg.Endpoint) buckets, err := client.ListBuckets(context.Background()) fmt.Println("buckets", buckets) fmt.Println("err", err) // return return &Client{ client: client, cfg: cfg, }, nil }