非官方百度云 Go 语言 SDK baidubce-sdk-go

baidubce-sdk-go 是非官方百度云API的Go语言SDK。目前提供了BOS(百度云对象存储)Go SDK。简化了API调用。

安装

go get github.com/guoyao/baidubce-sdk-go/...

范例

import (
    "log"

    "github.com/guoyao/baidubce-sdk-go/bce"
    "github.com/guoyao/baidubce-sdk-go/bos"
    "github.com/guoyao/baidubce-sdk-go/util"
)

var credentials = bce.NewCredentials("AK", "SK")
var bceConfig = bce.NewConfig(credentials)
var bosConfig = bos.NewConfig(bceConfig)
var bosClient = bos.NewClient(bosConfig)

func CreateBucket() {
    bucketName := "baidubce-sdk-go"
	err := bosClient.CreateBucket(bucketName, nil)

	if err != nil {
		log.Println(err)
	} else {
		err := bosClient.DeleteBucket(bucketName, nil)

		if err != nil {
			log.Println(err)
		}
	}
}

项目地址:https://github.com/guoyao/baidubce-sdk-go

Posted in Go. Tags: . 没有评论 »