Created
July 10, 2019 19:16
-
-
Save jamesnaftel/9a577e99e00d75768ace20a7ccf3a87b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "log" | |
| "github.com/minio/minio-go" | |
| ) | |
| func main() { | |
| endpoint := "play.min.io:9000" | |
| accessKeyID := "Q3AM3UQ867SPQQA43P2F" | |
| secretAccessKey := "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG" | |
| useSSL := true | |
| // Initialize minio client object. | |
| minioClient, err := minio.New(endpoint, accessKeyID, secretAccessKey, useSSL) | |
| if err != nil { | |
| log.Fatalln(err) | |
| } | |
| // Make a new bucket called mymusic. | |
| bucketNames := []string{"my_bucket", "my"} | |
| location := "us-east-1" | |
| for _, testBucketName := range bucketNames { | |
| err = minioClient.MakeBucket(testBucketName, location) | |
| if err != nil { | |
| // Check to see if we already own this bucket (which happens if you run this twice) | |
| exists, err2 := minioClient.BucketExists(testBucketName) | |
| if err == nil && exists { | |
| log.Printf("We already own %s\n", testBucketName) | |
| } else { | |
| log.Printf("MakeBucket error: %v, BucketExists error: %v\n", err, err2) | |
| } | |
| } else { | |
| log.Printf("Successfully created %s\n", testBucketName) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment