GithubHelp home page GithubHelp logo

panol / alibaba-cloud-sdk-go Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aliyun/alibaba-cloud-sdk-go

1.0 2.0 0.0 10.8 MB

Aliyun(Alibaba Cloud) Official SDK for the Go programming language.

License: Apache License 2.0

Makefile 0.01% Go 100.00%

alibaba-cloud-sdk-go's Introduction

Alibaba Cloud Go Software Development Kit

Build Status Go Report Card codecov

中文文档

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)
}

alibaba-cloud-sdk-go's People

Contributors

ailan-gl avatar conan425 avatar jacksontian avatar jimmy-zha avatar jxyowen avatar morlay avatar qingtang-sdk avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.