This topic describes how to install SDK for Go and provides an example of how to use SDK for Go.

Install SDK for Go

SDK for Go supports Go 1.7 and later. You can install SDK for Go by using one of the following methods:

  • (Recommended) Use glide.

    Run the following command:

    glide get
  • Use govendor.

    Run the following command:

    go get -u

Example of using SDK for Go

The following example uses SDK for Go to describe how to create a resource account:

package main

import (


func main() {
    // Construct an Alibaba Cloud client to send requests.
    // When you construct the client, configure the AccessKey ID and AccessKey secret.
    // Resource Management is a global service. However, the Resource Management API endpoint is located in the China (Shanghai) region. Therefore, set the region to cn-shanghai.
    client, err := resourcemanager.NewClientWithAccessKey("cn-shanghai", "<accessKeyId>", "<accessSecret>")

    // Construct the request object.
    request := resourcemanager.CreateCreateResourceAccountRequest()
    request.Scheme = "https"

    // Specify the required parameters.
    request.DisplayName = "test"

    // Issue the request and obtain a response.
    response, err := client.CreateResourceAccount(request)
    if err ! = nil {
    fmt.Printf("response is %#v\n", response)