This topic describes the sample code of the OSS Go SDK in various use cases.

SDK source code and API documents

For the source code of the OSS Go SDK, visit GitHub. For more information, see OSS Go SDK API documents.

Sample programs

The OSS Go SDK provides a variety of sample programs for your reference or use. The following table describes the sample programs provided.

Sample file Content
new_bucket.go Initialization
put_object.go Upload objects, including Simple upload and Resumable upload
append_object.go Append upload
get_object.go Download objects, including Streaming download, Conditional download, and Download a compressed object
delete_object.go Delete objects
copy_object.go Copy objects within the same bucket, Copy objects, and Copy objects
list_objects.go List objects, including listing objects with a specified prefix and listing a specified number of objects
object_meta.go Manage Object Meta
object_acl.go Manage ACL for an object
sign_url.go Authorized access
cname_sample.go Initialization
create_bucket.go Create a bucket
list_buckets.go Bucket based on default or specified parameters
bucket_acl.go Bucket
bucket_referer.go Add, query, and delete the Hotlink protection configurations for a bucket
bucket_logging.go Add, query, and delete the Set logging configurations for a bucket
bucket_lifecycle.go Add, query, and delete the Manage lifecycle rules for a bucket
bucket_cors.go Add, query, and delete the CORS configurations for a bucket
object_tagging.go Configure object tagging, Obtain the tags added to an object, Delete the tags added to an object, and Object tagging and lifecycle rules.
bucket_requestpayment.go Enable the Pay-by-requester mode
bucket_encryption.go Add, query, and delete the Server-side encryption configurations for a bucket