本文整理匯總了Golang中github.com/bluet-deps/aws-sdk-go/aws.String函數的典型用法代碼示例。如果您正苦於以下問題:Golang String函數的具體用法?Golang String怎麽用?Golang String使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了String函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ExampleSQS_AddPermission
func ExampleSQS_AddPermission() {
svc := sqs.New(session.New())
params := &sqs.AddPermissionInput{
AWSAccountIds: []*string{ // Required
aws.String("String"), // Required
// More values...
},
Actions: []*string{ // Required
aws.String("String"), // Required
// More values...
},
Label: aws.String("String"), // Required
QueueUrl: aws.String("String"), // Required
}
resp, err := svc.AddPermission(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例2: ExampleCloudWatch_DescribeAlarms
func ExampleCloudWatch_DescribeAlarms() {
svc := cloudwatch.New(session.New())
params := &cloudwatch.DescribeAlarmsInput{
ActionPrefix: aws.String("ActionPrefix"),
AlarmNamePrefix: aws.String("AlarmNamePrefix"),
AlarmNames: []*string{
aws.String("AlarmName"), // Required
// More values...
},
MaxRecords: aws.Int64(1),
NextToken: aws.String("NextToken"),
StateValue: aws.String("StateValue"),
}
resp, err := svc.DescribeAlarms(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例3: ExampleWorkSpaces_DescribeWorkspaces
func ExampleWorkSpaces_DescribeWorkspaces() {
svc := workspaces.New(session.New())
params := &workspaces.DescribeWorkspacesInput{
BundleId: aws.String("BundleId"),
DirectoryId: aws.String("DirectoryId"),
Limit: aws.Int64(1),
NextToken: aws.String("PaginationToken"),
UserName: aws.String("UserName"),
WorkspaceIds: []*string{
aws.String("WorkspaceId"), // Required
// More values...
},
}
resp, err := svc.DescribeWorkspaces(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例4: Test200WithErrorUnmarshalError
func Test200WithErrorUnmarshalError(t *testing.T) {
s := s3.New(unit.Session)
s.Handlers.Send.Clear()
s.Handlers.Send.PushBack(func(r *request.Request) {
r.HTTPResponse = &http.Response{
StatusCode: 200,
Header: http.Header{"X-Amz-Request-Id": []string{"abc123"}},
Body: ioutil.NopCloser(strings.NewReader(completeMultiErrResp)),
ContentLength: -1,
}
r.HTTPResponse.Status = http.StatusText(r.HTTPResponse.StatusCode)
})
_, err := s.CompleteMultipartUpload(&s3.CompleteMultipartUploadInput{
Bucket: aws.String("bucket"), Key: aws.String("key"),
UploadId: aws.String("id"),
MultipartUpload: &s3.CompletedMultipartUpload{Parts: []*s3.CompletedPart{
{ETag: aws.String("etag"), PartNumber: aws.Int64(1)},
}},
})
assert.Error(t, err)
assert.Equal(t, "SomeException", err.(awserr.Error).Code())
assert.Equal(t, "Exception message", err.(awserr.Error).Message())
assert.Equal(t, "abc123", err.(awserr.RequestFailure).RequestID())
}
示例5: TestPresignHandler
func TestPresignHandler(t *testing.T) {
svc := s3.New(unit.Session)
req, _ := svc.PutObjectRequest(&s3.PutObjectInput{
Bucket: aws.String("bucket"),
Key: aws.String("key"),
ContentDisposition: aws.String("a+b c$d"),
ACL: aws.String("public-read"),
})
req.Time = time.Unix(0, 0)
urlstr, err := req.Presign(5 * time.Minute)
assert.NoError(t, err)
expectedDate := "19700101T000000Z"
expectedHeaders := "host;x-amz-acl"
expectedSig := "7edcb4e3a1bf12f4989018d75acbe3a7f03df24bd6f3112602d59fc551f0e4e2"
expectedCred := "AKID/19700101/mock-region/s3/aws4_request"
u, _ := url.Parse(urlstr)
urlQ := u.Query()
assert.Equal(t, expectedSig, urlQ.Get("X-Amz-Signature"))
assert.Equal(t, expectedCred, urlQ.Get("X-Amz-Credential"))
assert.Equal(t, expectedHeaders, urlQ.Get("X-Amz-SignedHeaders"))
assert.Equal(t, expectedDate, urlQ.Get("X-Amz-Date"))
assert.Equal(t, "300", urlQ.Get("X-Amz-Expires"))
assert.NotContains(t, urlstr, "+") // + encoded as %20
}
示例6: TestDownloadError
func TestDownloadError(t *testing.T) {
s, names, _ := dlLoggingSvc([]byte{1, 2, 3})
num := 0
s.Handlers.Send.PushBack(func(r *request.Request) {
num++
if num > 1 {
r.HTTPResponse.StatusCode = 400
r.HTTPResponse.Body = ioutil.NopCloser(bytes.NewReader([]byte{}))
}
})
d := s3manager.NewDownloaderWithClient(s, func(d *s3manager.Downloader) {
d.Concurrency = 1
d.PartSize = 1
})
w := &aws.WriteAtBuffer{}
n, err := d.Download(w, &s3.GetObjectInput{
Bucket: aws.String("bucket"),
Key: aws.String("key"),
})
assert.NotNil(t, err)
assert.Equal(t, int64(1), n)
assert.Equal(t, []string{"GetObject", "GetObject"}, *names)
assert.Equal(t, []byte{1}, w.Bytes())
}
示例7: ExampleCloudWatchLogs_PutLogEvents
func ExampleCloudWatchLogs_PutLogEvents() {
svc := cloudwatchlogs.New(session.New())
params := &cloudwatchlogs.PutLogEventsInput{
LogEvents: []*cloudwatchlogs.InputLogEvent{ // Required
{ // Required
Message: aws.String("EventMessage"), // Required
Timestamp: aws.Int64(1), // Required
},
// More values...
},
LogGroupName: aws.String("LogGroupName"), // Required
LogStreamName: aws.String("LogStreamName"), // Required
SequenceToken: aws.String("SequenceToken"),
}
resp, err := svc.PutLogEvents(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例8: ExampleELB_RemoveTags
func ExampleELB_RemoveTags() {
svc := elb.New(session.New())
params := &elb.RemoveTagsInput{
LoadBalancerNames: []*string{ // Required
aws.String("AccessPointName"), // Required
// More values...
},
Tags: []*elb.TagKeyOnly{ // Required
{ // Required
Key: aws.String("TagKey"),
},
// More values...
},
}
resp, err := svc.RemoveTags(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例9: ExampleELB_ConfigureHealthCheck
func ExampleELB_ConfigureHealthCheck() {
svc := elb.New(session.New())
params := &elb.ConfigureHealthCheckInput{
HealthCheck: &elb.HealthCheck{ // Required
HealthyThreshold: aws.Int64(1), // Required
Interval: aws.Int64(1), // Required
Target: aws.String("HealthCheckTarget"), // Required
Timeout: aws.Int64(1), // Required
UnhealthyThreshold: aws.Int64(1), // Required
},
LoadBalancerName: aws.String("AccessPointName"), // Required
}
resp, err := svc.ConfigureHealthCheck(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例10: ExampleELB_CreateLoadBalancerListeners
func ExampleELB_CreateLoadBalancerListeners() {
svc := elb.New(session.New())
params := &elb.CreateLoadBalancerListenersInput{
Listeners: []*elb.Listener{ // Required
{ // Required
InstancePort: aws.Int64(1), // Required
LoadBalancerPort: aws.Int64(1), // Required
Protocol: aws.String("Protocol"), // Required
InstanceProtocol: aws.String("Protocol"),
SSLCertificateId: aws.String("SSLCertificateId"),
},
// More values...
},
LoadBalancerName: aws.String("AccessPointName"), // Required
}
resp, err := svc.CreateLoadBalancerListeners(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例11: ExampleELB_CreateLoadBalancerPolicy
func ExampleELB_CreateLoadBalancerPolicy() {
svc := elb.New(session.New())
params := &elb.CreateLoadBalancerPolicyInput{
LoadBalancerName: aws.String("AccessPointName"), // Required
PolicyName: aws.String("PolicyName"), // Required
PolicyTypeName: aws.String("PolicyTypeName"), // Required
PolicyAttributes: []*elb.PolicyAttribute{
{ // Required
AttributeName: aws.String("AttributeName"),
AttributeValue: aws.String("AttributeValue"),
},
// More values...
},
}
resp, err := svc.CreateLoadBalancerPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例12: ExampleCloudFormation_EstimateTemplateCost
func ExampleCloudFormation_EstimateTemplateCost() {
svc := cloudformation.New(session.New())
params := &cloudformation.EstimateTemplateCostInput{
Parameters: []*cloudformation.Parameter{
{ // Required
ParameterKey: aws.String("ParameterKey"),
ParameterValue: aws.String("ParameterValue"),
UsePreviousValue: aws.Bool(true),
},
// More values...
},
TemplateBody: aws.String("TemplateBody"),
TemplateURL: aws.String("TemplateURL"),
}
resp, err := svc.EstimateTemplateCost(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例13: ExampleSQS_ChangeMessageVisibilityBatch
func ExampleSQS_ChangeMessageVisibilityBatch() {
svc := sqs.New(session.New())
params := &sqs.ChangeMessageVisibilityBatchInput{
Entries: []*sqs.ChangeMessageVisibilityBatchRequestEntry{ // Required
{ // Required
Id: aws.String("String"), // Required
ReceiptHandle: aws.String("String"), // Required
VisibilityTimeout: aws.Int64(1),
},
// More values...
},
QueueUrl: aws.String("String"), // Required
}
resp, err := svc.ChangeMessageVisibilityBatch(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例14: ExampleSQS_ReceiveMessage
func ExampleSQS_ReceiveMessage() {
svc := sqs.New(session.New())
params := &sqs.ReceiveMessageInput{
QueueUrl: aws.String("String"), // Required
AttributeNames: []*string{
aws.String("QueueAttributeName"), // Required
// More values...
},
MaxNumberOfMessages: aws.Int64(1),
MessageAttributeNames: []*string{
aws.String("MessageAttributeName"), // Required
// More values...
},
VisibilityTimeout: aws.Int64(1),
WaitTimeSeconds: aws.Int64(1),
}
resp, err := svc.ReceiveMessage(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例15: ExampleECS_UpdateService
func ExampleECS_UpdateService() {
svc := ecs.New(session.New())
params := &ecs.UpdateServiceInput{
Service: aws.String("String"), // Required
Cluster: aws.String("String"),
DeploymentConfiguration: &ecs.DeploymentConfiguration{
MaximumPercent: aws.Int64(1),
MinimumHealthyPercent: aws.Int64(1),
},
DesiredCount: aws.Int64(1),
TaskDefinition: aws.String("String"),
}
resp, err := svc.UpdateService(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}