req, resp := svc.ListBucketsRequest(nil) err := req.Send() if err == nil { // success fmt.Printf("Buckets:\n") for _, bucket := range resp.Buckets { fmt.Printf("%s : %s\n", *bucket.Name, bucket.CreationDate) } }
req, _ := svc.GetObjectRequest(&s3.GetObjectInput{ Bucket: aws.String(bucket_name), Key: aws.String(key), }) url, err := req.Presign(15 * time.Minute) // create a pre-signed URL if err != nil { log.Fatalf("Failed to sign request: %v", err) } fmt.Println("Download link:") fmt.Println(url)This code creates a pre-signed URL for getting an object from the specified bucket and key in the AWS S3 service. The pre-signed URL is valid for 15 minutes, allowing a user to download the object without having to authenticate with AWS. Overall, the github.com/aws/aws-sdk-go/aws/request package is a very useful tool for interacting with AWS services in a Go application. It provides a simple and easy-to-use interface for making requests and handling responses.