English | 简体中文 | 日本語
Alibaba Cloud SDK for Go
Alibaba Cloud SDK for Go allows you to access Alibaba Cloud services such as Elastic Compute Service (ECS), Server Load Balancer (SLB), and CloudMonitor. You can access Alibaba Cloud services without the need to handle API related tasks, such as signing and constructing your requests.
This document introduces how to obtain and call Alibaba Cloud SDK for Go.
Troubleshoot
Troubleshoot Provide OpenAPI diagnosis service to help developers locate quickly and provide solutions for developers through RequestID
or error message
.
Online Demo
Alibaba Cloud OpenAPI Developer Portal provides the ability to call the cloud product OpenAPI online, and dynamically generate SDK Example code and quick retrieval interface, which can significantly reduce the difficulty of using the cloud API.
Requirements
- It's necessary for you to make sure your system meet the Requirements, such as installing a Go environment which is new than 1.13.x.
Installation
Use go get
to install SDK:
go get -u github.com/aliyun/alibaba-cloud-sdk-go/sdk
Quick Examples
Before you begin, you need to sign up for an Alibaba Cloud account and retrieve your Credentials.
Create Client
package main
import "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
func main() {
client, err := sdk.NewClientWithAccessKey("REGION_ID", "ACCESS_KEY_ID", "ACCESS_KEY_SECRET")
if err != nil {
panic(err)
}
}
ROA Request
package main
import "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
func main() {
request := requests.NewCommonRequest()
request.Method = "GET"
request.Product = "CS"
request.Domain = "cs.aliyuncs.com"
request.Version = "2015-12-15"
request.PathPattern = "/clusters/[ClusterId]"
request.Scheme = "https"
request.ApiName = "DescribeCluster"
request.QueryParams["ClusterId"] = "123456"
request.QueryParams["RegionId"] = "region_id"
request.TransToAcsRequest()
}
RPC Request
package main
import "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
func main() {
request := requests.NewCommonRequest()
request.Method = "POST"
request.Product = "Ecs"
request.Domain = "ecs.aliyuncs.com"
request.Version = "2014-05-26"
request.Scheme = "https"
request.ApiName = "CreateInstance"
request.QueryParams["InstanceType"] = "ecs.g5.large"
request.QueryParams["RegionId"] = "region_id"
request.TransToAcsRequest()
}
Documentation
Issues
Opening an Issue, Issues not conforming to the guidelines may be closed immediately.
Contribution
Please make sure to read the Contributing Guide before making a pull request.
References
License