暫無描述

jxyowen 0c29015e80 travis 7 年之前
integration 5ff4ad1f9f add zoneinfo 7 年之前
sdk 2a2352bf62 add zoneinfo 7 年之前
services 1c9ff51e1e 由智久发起的CDN SDK自动发布, 版本号:1.12.1 7 年之前
vendor 63b09c9b66 repalce glide with dep and moodify .travis.yml 7 年之前
.gitignore d974c5f8d9 ignore 7 年之前
.travis.yml 0c29015e80 travis 7 年之前
ChangeLog.txt 1c9ff51e1e 由智久发起的CDN SDK自动发布, 版本号:1.12.1 7 年之前
Gopkg.lock 2a2352bf62 add zoneinfo 7 年之前
Gopkg.toml 2a2352bf62 add zoneinfo 7 年之前
LICENSE e2e8a5b9ca Initial commit 8 年之前
README.md 6c7426938c add readme 7 年之前
README_zh.md af7443235d add readme 7 年之前

README.md

Alibaba Cloud Go Software Development Kit

Build Status Go Report Card

中文文档

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.

Prerequisites

  • 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:

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.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
    "fmt"
)

func main() { 
    // Create an ECS client
    ecsClient, err := ecs.NewClientWithAccessKey(
        "<your-region-id>",             // Your Region ID
        "<your-access-key-id>",         // Your AccessKey ID
        "<your-access-key-secret>")     // Your AccessKey Secret
    if err != nil {
        // Handle exceptions
        panic(err)
    }
    // Create an API request and set parameters
    request := ecs.CreateDescribeInstancesRequest()
    // Set the request.PageSize to "10"
    request.PageSize = requests.NewInteger(10)
    // Initiate the request and handle exceptions
    response, err := ecsClient.DescribeInstances(request)
    if err != nil {
        // Handle exceptions
        panic(err)
    }
    fmt.Println(response)
}