This tutorial uses the CreateLoadBalancer API of SLB to show you how to use Alibaba Cloud Go SDK to call SLB APIs.

Alibaba Cloud Server Load Balancer (SLB) is a traffic distribution control service that distributes the incoming traffic among multiple Elastic Compute Service (ECS) instances according to the configured forwarding rules. It expands the service capabilities of the application and increases the availability of the application. 

Code example

Notice Running the code in this example will create an SLB instance and generate fees.
package main

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


func main() { 
    // Create the slbClient instance
    client, err := slb.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 a request and set parameters
    request := slb.CreateCreateLoadBalancerRequest()
    request.LoadBalancerName = "MyLoadBalancer"
    request.AddressType = "internet"
    request.ClientToken = utils.GetUUIDV4() 
    response, err := client.CreateLoadBalancer(request)    
    if err ! = nil {
        // Handle exceptions
        panic(err)
    
    fmt.Printf("success(%d)! loadBalancerId = %s\n", response.GetHttpStatus(), response.LoadBalancerId)