A bucket is a container for objects stored in OSS. Every object is contained in a bucket. This topic describes how to query information about a bucket.

The following code provides an example on how to query the information about a bucket, including the region, creation date, and ACL of the bucket.

package main

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

func main() {
    // Create an OSSClient instance.
    client, err := oss.New("<yourEndpoint>", "<yourAccessKeyId>", "<yourAccessKeySecret>")
    if err ! = nil {
        fmt.Println("Error:", err)
        os.Exit(-1)
    }

    // Query the information about a bucket, including the region (Region or Location), creation date (CreationDate), permissions (ACL), owner (Owner), and storage class (StorageClass) of the bucket.
    res, err := client.GetBucketInfo("<yourBucketName>")
    if err ! = nil {
        fmt.Println("Error:", err)
        os.Exit(-1)
    }
    fmt.Println("BucketInfo.Location: ", res.BucketInfo.Location)
    fmt.Println("BucketInfo.CreationDate: ", res.BucketInfo.CreationDate)
    fmt.Println("BucketInfo.ACL: ", res.BucketInfo.ACL)
    fmt.Println("BucketInfo.Owner: ", res.BucketInfo.Owner)
    fmt.Println("BucketInfo.StorageClass: ", res.BucketInfo.StorageClass)
    fmt.Println("BucketInfo.RedundancyType: ", res.BucketInfo.RedundancyType)
    fmt.Println("BucketInfo.ExtranetEndpoint: ", res.BucketInfo.ExtranetEndpoint)
    fmt.Println("BucketInfo.IntranetEndpoint: ", res.BucketInfo.IntranetEndpoint)
}
		

For more information about how to query information about a bucket, see GetBucketInfo.