Skip to content

Instantly share code, notes, and snippets.

@hekki
Last active November 16, 2024 14:45
Show Gist options
  • Save hekki/5d98f764e6e4cfe91309f54a17b3db96 to your computer and use it in GitHub Desktop.
Save hekki/5d98f764e6e4cfe91309f54a17b3db96 to your computer and use it in GitHub Desktop.
さくらのクラウドのオブジェクトストレージをaws-sdk-go-v2から扱うサンプルコード
package main
import (
"context"
"fmt"
"log"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/s3"
)
var (
baseEndpoint = "https://s3.isk01.sakurastorage.jp"
)
func main() {
ctx := context.Background()
cfg, err := config.LoadDefaultConfig(ctx)
if err != nil {
log.Fatalln(err)
}
client := s3.NewFromConfig(cfg, func(options *s3.Options) {
options.BaseEndpoint = &baseEndpoint
})
bs, err := client.ListBuckets(ctx, nil)
if err != nil {
panic(err)
}
for _, b := range bs.Buckets {
fmt.Println(*b.Name)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment