edit-icon download-icon

Getting started

Last Updated: Mar 23, 2018

The Alibaba Cloud Go Software Development Kit (SDK) 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 Go SDK.

If you have any problem while using Go SDK, please join the DingTalk group: 11771185 (the official SDK customer service group of Alibaba Cloud) for consultation.


  • To use Alibaba Cloud Go SDK, you must have an Alibaba Cloud account as well as an AccessKey.

    The AccessKey is required when initializing AcsClient. You can create an AccessKey in the Alibaba Cloud console. For more information, see Create an AccessKey.

    Note: To increase the security of your account, we recommend that you use the AccessKey of the RAM user to access Alibaba Cloud services.

  • To use Alibaba Cloud Go SDK to access the APIs of a product, you must first activate the product on the Alibaba Cloud console if required.

Install Go SDK

Run the following commands to install Alibaba Cloud Go SDK:

  1. glide get github.com/aliyun/alibaba-cloud-sdk-go

Use Go SDK

The following code example shows the three main steps to use Alibaba Cloud Go SDK:

  1. Create the client.

  2. Create an API request and set parameters.

  3. Initiate the request and handle exceptions.

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
  5. "fmt"
  6. )
  7. func main() {
  8. // Create an ECS client
  9. ecsClient, err := ecs.NewClientWithAccessKey(
  10. "<your-region-id>", // Your Region ID
  11. "<your-access-key-id>", // Your AccessKey ID
  12. "<your-access-key-secret>") // Your AccessKey Secret
  13. if err != nil {
  14. // Handle exceptions
  15. panic(err)
  16. }
  17. // Create an API request and set parameters
  18. request := ecs.CreateDescribeInstancesRequest()
  19. // Set the request.PageSize to "10"
  20. request.PageSize = requests.NewInteger(10)
  21. // Initiate the request and handle exceptions
  22. response, err := ecsClient.DescribeInstances(request)
  23. if err != nil {
  24. // Handle exceptions
  25. panic(err)
  26. }
  27. fmt.Println(response)
  28. }
Thank you! We've received your feedback.