Skip to content

Instantly share code, notes, and snippets.

@gevorgyana
Created November 26, 2020 16:21
Show Gist options
  • Save gevorgyana/7c1fdb3c422c0cf4fadf7e02c8e69ddc to your computer and use it in GitHub Desktop.
Save gevorgyana/7c1fdb3c422c0cf4fadf7e02c8e69ddc to your computer and use it in GitHub Desktop.
/*
* MinIO Go Library for Amazon S3 Compatible Cloud Storage
* Copyright 2015-2017 MinIO, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package main
import (
"context"
"log"
"time"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
)
func main() {
var endpoint string = "127.0.0.1:9000"
var accessKey string = "minio"
var secretKey string = "minio123"
var err error
var mClient *minio.Client
mClient, err = minio.New(endpoint, &minio.Options{
Creds: credentials.NewStaticV4(accessKey, secretKey, ""),
Secure: true,
})
if err != nil {
log.Fatalln(err)
}
log.Println("alright")
opts := minio.MakeBucketOptions{
Region: "us-east-1",
}
root_ctx := context.Background()
ctx, _ := context.WithTimeout(root_ctx, 5*time.Second)
// Let's give it 5 seconds to complete
err = mClient.MakeBucket(ctx, "my-bucketname", opts)
if err != nil {
log.Fatalln(err)
}
log.Println("Success")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment