This topic describes how to install SDKs for Go and provides sample code.

Background information

Installation

For more information about how to install the SDKs for Go, see Get started.

You can download the installation packages of the SDKs for Go from the following links:

Example

The following code provides an example on how to use Resource Management SDK for Go to call the CreateResourceAccount API operation. You can use OpenAPI Developer Portal to debug other API operations and obtain their sample code.

package main

import (
    "fmt"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/resourcemanager"

)

func main() {
    // Construct an Alibaba Cloud client that is used to initiate requests.
    // When you construct the client, specify your AccessKey ID and AccessKey secret.
    client, err := resourcemanager.NewClientWithAccessKey("cn-shanghai", "<accessKeyId>", "<accessKeySecret>")

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

    // Specify request parameters. For more information about the parameters, see API Reference.
    request.DisplayName = "<DisplayName>"

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