All Products
Document Center

Object Storage Service:Installation

Last Updated:Dec 12, 2023

OSS SDK for Go allows you to programmatically manage resources in Object Storage Service (OSS). For example, you can manage buckets, upload objects, download objects, and process images. This topic describes how to install OSS SDK for Go.

Environment preparations

  • Environment requirements

    Golang 1.6 or later is required.

    For more information about how to download and install the environment for OSS SDK for Go, visit Installing Go from source. After OSS SDK for Go is installed, create a new system variable GOPATH, and set the value to your code directory. For more information about GOPATH, run the go help gopath command.

  • Check the version of OSS SDK for Go

    Run the go version command to view the version of Go.

Download OSS SDK for Go

Install OSS SDK for Go

Go mod

Add the following dependency to the go.mod file. In the following example, OSS SDK for Go 2.2.6 is used. If you use another version, use the number of the version.

require ( v2.2.6+incompatible

Source code

go get

No messages appear during the installation. The installation requires a few minutes to complete. If the installation fails, run the preceding command again.

Verify whether OSS SDK for Go is installed

Run the following code to query the version of OSS SDK for Go:

package main

import (

func main() {
  fmt.Println("OSS Go SDK Version: ", oss.Version)

What to do next

After you install OSS SDK for Go, you need to configure access credentials. For more information, see Configure access credentials.