In a bucket with versioning enabled or suspended, the storage class of each version of an object can be different. RestoreObject restores the current version of the target object by default. You can specify the versionId in the request to restore the specified version of the object.

You can run the following code to restore an object:
package main

import (
  "fmt"
  "os"
  "time"
  "strings"
  "github.com/aliyun/aliyun-oss-go-sdk/oss"
)

func HandleError(err error) {
  fmt.Println("Error:", err)
  os.Exit(-1)
}

func main() {
  // Creates an OSSClient instance.
  client, err := oss.New("<yourEndpoint>", "<yourAccessKeyId>", "<yourAccessKeySecret>")
  if err != nil {
    HandleError(err)
  }

  bucketName := "<yourBucketName>"
  objectName := "<yourObjectName>"
  localFilename := "<yourLocalFilename>"

  // Creates a bucket of the Archive storage class.
  err = client.CreateBucket(bucketName, oss.StorageClass(oss.StorageArchive))
  if err != nil {
    HandleError(err)
  }
  // Enables the versioning function of the bucket.
  config := oss.VersioningConfig{Status: "Enabled"}
  err = client.SetBucketVersioning(bucketName, config)
  if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
  }

  // Obtains the bucket.
  archiveBucket, err := client.Bucket(bucketName)
  if err != nil {
    HandleError(err)
  }

  var retHeader http.Header
  // Uploads a string. The oss.GetResponseHeader method is used to obtain the returned header.
  err = archiveBucket.PutObject("<yourObjectName>", strings.NewReader("yourObjectValue"), oss.GetResponseHeader(&retHeader))
  if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
  }
  // Obtains the versionId of the uploaded object to be restored.
  versionId := oss.GetVersionId(retHeader)

  // Checks whether the storage class of the object is Archive.
  meta, err := archiveBucket.GetObjectDetailedMeta(objectName, oss.VersionId(versionId))
  if err != nil {
    HandleError(err)
  }

  if meta.Get("X-Oss-Storage-Class") == string(oss.StorageArchive) {
    err = archiveBucket.RestoreObject(objectName, oss.VersionId(versionId))
    if err != nil {
      HandleError(err)
    }

    // Waits until the object is restored.
    meta, err = archiveBucket.GetObjectDetailedMeta(objectName, oss.VersionId(versionId))
    for meta.Get("X-Oss-Restore") == "ongoing-request=\"true\"" {
      fmt.Println("x-oss-restore:" + meta.Get("X-Oss-Restore"))
      time.Sleep(1000 * time.Second)
      meta, err = archiveBucket.GetObjectDetailedMeta(objectName, oss.VersionId(versionId))
    }
  }

  // Downloads the restored object.
  err = archiveBucket.GetObjectToFile(objectName, localFilename, oss.VersionId(versionId))
  if err != nil {
    HandleError(err)
  }
}