Skip to content

Go SDK Quick Start

This article provides a quick start guide for using the Go SDK for common operations. You will learn how to install the SDK, configure access credentials, and perform basic operations such as obtaining the latest upgrade information.

Notes

  • To make requests using the Go SDK, you need to initialize a Client instance. This article creates a Client by loading default configurations. For more configuration options for the client, see Configure Client.

Prerequisites

  • Already registered an UpgradeLink account.
  • Obtained AccessKey and AccessSecret.
  • Configured URL application upgrade strategy.

Get Credentials

img.jpg

Install Go SDK

  • Please install Go 1.5 or later version of the compilation and running environment first. Check if Go is installed successfully using the following command:
shell
  go version

If you don't have a suitable Go compilation and running environment currently, please refer to Golang Installation for downloading and installing.

  • Create a project directory and initialize a Go module.
shell
  mkdir upgrade-go-example && cd upgrade-go-example && go mod init upgrade-go-example
  • Execute the following command to obtain the remote code package.
shell
go get github.com/toolsetlink/upgradelink-api-go
  • Import the Go SDK package in your project using the following code.
go
import "github.com/toolsetlink/upgradelink-api-go"

Quick Usage

The following sample program demonstrates how to initialize the Client and obtain the latest upgrade information for URL applications.

Get the Latest Upgrade Information for URL Applications

go

package test

import (
	"fmt"
	"testing"

	"github.com/toolsetlink/upgradelink-api-go/client"
)

// Get URL application upgrade content
func TestGetUrlUpgrade(t *testing.T) {

	var config = client.Config{}
	config.SetAccessKey("mui2W50H1j-OC4xD6PgQag")
	config.SetAccessSecret("PEbdHFGC0uO_Pch7XWBQTMsFRxKPQAM2565eP8LJ3gc")

	Client, err := client.NewClient(&config)
	if err != nil {
		return
	}

	urlKey := "uJ47NPeT7qjLa1gL3sVHqw"
	versionCode := 1
	appointVersionCode := 0
	devModelKey := ""
	devKey := ""

	// Interface call
	request := &client.UrlUpgradeRequest{
		UrlKey:             &urlKey,
		VersionCode:        &versionCode,
		AppointVersionCode: &appointVersionCode,
		DevModelKey:        &devModelKey,
		DevKey:             &devKey,
	}
	Info, err := Client.UrlUpgrade(request)
	if err != nil {
		fmt.Println("err: ", err)
	} else {
		fmt.Println("info: ", Info)
	}

}

toolsetlink@163.com