Skip to content

Commit 82789cd

Browse files
authored
Go: Update all Go snippet tags to include imports in the snippets. (#7036)
Update all Go snippet tags to include imports in the snippets.
1 parent fed362b commit 82789cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+271
-246
lines changed

.doc_gen/metadata/bedrock-runtime_metadata.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ bedrock-runtime_InvokeModel_Ai21LabsJurassic2:
555555
excerpts:
556556
- description: Use the Invoke Model API to send a text message.
557557
snippet_tags:
558+
- gov2.bedrock-runtime.InvokeModelWrapper.struct
558559
- gov2.bedrock-runtime.InvokeJurassic2
559560
JavaScript:
560561
versions:
@@ -620,6 +621,7 @@ bedrock-runtime_InvokeModel_TitanText:
620621
excerpts:
621622
- description: Use the Invoke Model API to send a text message.
622623
snippet_tags:
624+
- gov2.bedrock-runtime.InvokeModelWrapper.struct
623625
- gov2.bedrock-runtime.InvokeTitanText
624626
services:
625627
bedrock-runtime: {InvokeModel}
@@ -669,6 +671,7 @@ bedrock-runtime_InvokeModel_AnthropicClaude:
669671
excerpts:
670672
- description: Invoke the Anthropic Claude 2 foundation model to generate text.
671673
snippet_tags:
674+
- gov2.bedrock-runtime.InvokeModelWrapper.struct
672675
- gov2.bedrock-runtime.InvokeClaude
673676
PHP:
674677
versions:
@@ -799,6 +802,7 @@ bedrock-runtime_InvokeModel_MetaLlama2:
799802
excerpts:
800803
- description: Use the Invoke Model API to send a text message.
801804
snippet_tags:
805+
- gov2.bedrock-runtime.InvokeModelWrapper.struct
802806
- gov2.bedrock-runtime.InvokeLlama2
803807
JavaScript:
804808
versions:
@@ -972,6 +976,7 @@ bedrock-runtime_InvokeModelWithResponseStream_AnthropicClaude:
972976
excerpts:
973977
- description: Use the Invoke Model API to send a text message and process the response stream in real-time.
974978
snippet_tags:
979+
- gov2.bedrock-runtime.InvokeModelWrapper.struct
975980
- gov2.bedrock-runtime.InvokeModelWithResponseStream
976981
JavaScript:
977982
versions:
@@ -1195,6 +1200,7 @@ bedrock-runtime_InvokeModel_TitanImageGenerator:
11951200
excerpts:
11961201
- description: Create an image with the Amazon Titan Image Generator.
11971202
snippet_tags:
1203+
- gov2.bedrock-runtime.InvokeModelWrapper.struct
11981204
- gov2.bedrock-runtime.InvokeTitanImage
11991205
PHP:
12001206
versions:

.doc_gen/metadata/dynamodb_metadata.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ dynamodb_BatchWriteItem:
394394
snippet_tags:
395395
- gov2.dynamodb.TableBasics.struct
396396
- gov2.dynamodb.BatchWriteItem
397+
- description: Define a Movie struct that is used in this example.
398+
snippet_tags:
397399
- gov2.dynamodb.Movie.struct
398400
Java:
399401
versions:
@@ -643,6 +645,8 @@ dynamodb_PutItem:
643645
snippet_tags:
644646
- gov2.dynamodb.TableBasics.struct
645647
- gov2.dynamodb.PutItem
648+
- description: Define a Movie struct that is used in this example.
649+
snippet_tags:
646650
- gov2.dynamodb.Movie.struct
647651
Kotlin:
648652
versions:
@@ -780,6 +784,8 @@ dynamodb_GetItem:
780784
snippet_tags:
781785
- gov2.dynamodb.TableBasics.struct
782786
- gov2.dynamodb.GetItem
787+
- description: Define a Movie struct that is used in this example.
788+
snippet_tags:
783789
- gov2.dynamodb.Movie.struct
784790
Kotlin:
785791
versions:
@@ -908,6 +914,8 @@ dynamodb_UpdateItem:
908914
snippet_tags:
909915
- gov2.dynamodb.TableBasics.struct
910916
- gov2.dynamodb.UpdateItem
917+
- description: Define a Movie struct that is used in this example.
918+
snippet_tags:
911919
- gov2.dynamodb.Movie.struct
912920
Kotlin:
913921
versions:
@@ -1024,6 +1032,8 @@ dynamodb_DeleteItem:
10241032
snippet_tags:
10251033
- gov2.dynamodb.TableBasics.struct
10261034
- gov2.dynamodb.DeleteItem
1035+
- description: Define a Movie struct that is used in this example.
1036+
snippet_tags:
10271037
- gov2.dynamodb.Movie.struct
10281038
Kotlin:
10291039
versions:
@@ -1309,6 +1319,8 @@ dynamodb_Query:
13091319
snippet_tags:
13101320
- gov2.dynamodb.TableBasics.struct
13111321
- gov2.dynamodb.Query
1322+
- description: Define a Movie struct that is used in this example.
1323+
snippet_tags:
13121324
- gov2.dynamodb.Movie.struct
13131325
Kotlin:
13141326
versions:
@@ -1448,6 +1460,8 @@ dynamodb_Scan:
14481460
snippet_tags:
14491461
- gov2.dynamodb.TableBasics.struct
14501462
- gov2.dynamodb.Scan
1463+
- description: Define a Movie struct that is used in this example.
1464+
snippet_tags:
14511465
- gov2.dynamodb.Movie.struct
14521466
Kotlin:
14531467
versions:
@@ -1578,6 +1592,9 @@ dynamodb_ExecuteStatement:
15781592
- sdk_version: 2
15791593
github: gov2/dynamodb
15801594
excerpts:
1595+
- description: Define a function receiver struct for the example.
1596+
snippet_tags:
1597+
- gov2.dynamodb.PartiQLRunner.struct
15811598
- description: Use an INSERT statement to add an item.
15821599
snippet_tags:
15831600
- gov2.dynamodb.ExecuteStatement.Insert
@@ -1699,6 +1716,9 @@ dynamodb_BatchExecuteStatement:
16991716
- sdk_version: 2
17001717
github: gov2/dynamodb
17011718
excerpts:
1719+
- description: Define a function receiver struct for the example.
1720+
snippet_tags:
1721+
- gov2.dynamodb.PartiQLRunner.struct
17021722
- description: Use batches of INSERT statements to add items.
17031723
snippet_tags:
17041724
- gov2.dynamodb.BatchExecuteStatement.Insert

.doc_gen/metadata/lambda_metadata.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,9 +794,6 @@ lambda_Scenario_GettingStartedFunctions:
794794
- description: Create a struct that wraps individual &LAM; actions.
795795
snippet_tags:
796796
- gov2.lambda.FunctionWrapper.complete
797-
- description: Create a struct that implements functions to help run the scenario.
798-
snippet_tags:
799-
- gov2.lambda.GetStartedFunctions_Helper
800797
- description: Define a &LAM; handler that increments a number.
801798
snippet_tags:
802799
- gov2.lambda.handlers.increment

.doc_gen/metadata/s3_metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,6 +2742,7 @@ s3_Scenario_PresignedUrl:
27422742
- description: Run an interactive example that generates and uses presigned URLs to upload, download, and delete
27432743
an S3 object.
27442744
snippet_tags:
2745+
- gov2.s3.Scenario_Presigning.imports
27452746
- gov2.s3.Scenario_Presigning
27462747
- description: Define an HTTP request wrapper used by the example to make HTTP requests.
27472748
snippet_tags:

.doc_gen/metadata/sqs_metadata.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,9 @@ sqs_Scenario_TopicsAndQueues:
980980
- description: Define a struct that wraps &SQS; actions used in this example.
981981
snippet_tags:
982982
- gov2.sqs.SqsActions.complete
983+
- description: Clean up resources.
984+
snippet_tags:
985+
- gov2.workflows.TopicsAndQueues.Resources.complete
983986
JavaScript:
984987
versions:
985988
- sdk_version: 3

gov2/aurora/actions/clusters.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// SPDX-License-Identifier: Apache-2.0
33
package actions
44

5+
// snippet-start:[gov2.aurora.DbClusters.complete]
6+
// snippet-start:[gov2.aurora.DbClusters.struct]
7+
58
import (
69
"context"
710
"errors"
@@ -12,9 +15,6 @@ import (
1215
"github.com/aws/aws-sdk-go-v2/service/rds/types"
1316
)
1417

15-
// snippet-start:[gov2.aurora.DbClusters.complete]
16-
// snippet-start:[gov2.aurora.DbClusters.struct]
17-
1818
type DbClusters struct {
1919
AuroraClient *rds.Client
2020
}

gov2/aurora/scenarios/get_started_clusters.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
package scenarios
55

6+
// snippet-start:[gov2.aurora.Scenario_GetStartedClusters]
7+
68
import (
79
"aurora/actions"
810
"context"
@@ -21,26 +23,6 @@ import (
2123
"github.com/google/uuid"
2224
)
2325

24-
// IScenarioHelper abstracts the function from a scenario so that it
25-
// can be mocked for unit testing.
26-
type IScenarioHelper interface {
27-
Pause(secs int)
28-
UniqueId() string
29-
}
30-
type ScenarioHelper struct{}
31-
32-
// Pause waits for the specified number of seconds.
33-
func (helper ScenarioHelper) Pause(secs int) {
34-
time.Sleep(time.Duration(secs) * time.Second)
35-
}
36-
37-
// UniqueId returns a new UUID.
38-
func (helper ScenarioHelper) UniqueId() string {
39-
return uuid.New().String()
40-
}
41-
42-
// snippet-start:[gov2.aurora.Scenario_GetStartedClusters]
43-
4426
// GetStartedClusters is an interactive example that shows you how to use the AWS SDK for Go
4527
// with Amazon Aurora to do the following:
4628
//
@@ -384,4 +366,22 @@ func (scenario GetStartedClusters) Cleanup(ctx context.Context, dbInstance *type
384366
}
385367
}
386368

369+
// IScenarioHelper abstracts the function from a scenario so that it
370+
// can be mocked for unit testing.
371+
type IScenarioHelper interface {
372+
Pause(secs int)
373+
UniqueId() string
374+
}
375+
type ScenarioHelper struct{}
376+
377+
// Pause waits for the specified number of seconds.
378+
func (helper ScenarioHelper) Pause(secs int) {
379+
time.Sleep(time.Duration(secs) * time.Second)
380+
}
381+
382+
// UniqueId returns a new UUID.
383+
func (helper ScenarioHelper) UniqueId() string {
384+
return uuid.New().String()
385+
}
386+
387387
// snippet-end:[gov2.aurora.Scenario_GetStartedClusters]

gov2/bedrock-runtime/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,24 @@ functions within the same service.
4242

4343
### AI21 Labs Jurassic-2
4444

45-
- [InvokeModel](actions/invoke_model.go#L83)
45+
- [InvokeModel](actions/invoke_model.go#L7)
4646

4747
### Amazon Titan Image Generator
4848

49-
- [InvokeModel](actions/invoke_model.go#L191)
49+
- [InvokeModel](actions/invoke_model.go#L7)
5050

5151
### Amazon Titan Text
5252

53-
- [InvokeModel](actions/invoke_model.go#L261)
53+
- [InvokeModel](actions/invoke_model.go#L7)
5454

5555
### Anthropic Claude
5656

57-
- [InvokeModel](actions/invoke_model.go#L27)
57+
- [InvokeModel](actions/invoke_model.go#L7)
5858
- [InvokeModelWithResponseStream](actions/invoke_model_with_response_stream.go#L30)
5959

6060
### Meta Llama
6161

62-
- [InvokeModel: Llama 2](actions/invoke_model.go#L140)
62+
- [InvokeModel: Llama 2](actions/invoke_model.go#L7)
6363

6464

6565
<!--custom.examples.start-->

gov2/bedrock-runtime/actions/invoke_model.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
package actions
55

6+
// snippet-start:[gov2.bedrock-runtime.InvokeModelWrapper.complete]
7+
// snippet-start:[gov2.bedrock-runtime.InvokeModelWrapper.struct]
8+
69
import (
710
"context"
811
"encoding/json"
@@ -13,9 +16,6 @@ import (
1316
"github.com/aws/aws-sdk-go-v2/service/bedrockruntime"
1417
)
1518

16-
// snippet-start:[gov2.bedrock-runtime.InvokeModelWrapper.complete]
17-
// snippet-start:[gov2.bedrock-runtime.InvokeModelWrapper.struct]
18-
1919
// InvokeModelWrapper encapsulates Amazon Bedrock actions used in the examples.
2020
// It contains a Bedrock Runtime client that is used to invoke foundation models.
2121
type InvokeModelWrapper struct {

gov2/bedrock-runtime/actions/invoke_model_with_response_stream.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
package actions
55

6+
// snippet-start:[gov2.bedrock-runtime.InvokeModelWithResponseStreamWrapper.complete]
7+
// snippet-start:[gov2.bedrock-runtime.InvokeModelWithResponseStreamWrapper.struct]
8+
69
import (
710
"bytes"
811
"context"
@@ -16,9 +19,6 @@ import (
1619
"github.com/aws/aws-sdk-go-v2/service/bedrockruntime/types"
1720
)
1821

19-
// snippet-start:[gov2.bedrock-runtime.InvokeModelWithResponseStreamWrapper.complete]
20-
// snippet-start:[gov2.bedrock-runtime.InvokeModelWithResponseStreamWrapper.struct]
21-
2222
// InvokeModelWithResponseStreamWrapper encapsulates Amazon Bedrock actions used in the examples.
2323
// It contains a Bedrock Runtime client that is used to invoke foundation models.
2424
type InvokeModelWithResponseStreamWrapper struct {

0 commit comments

Comments
 (0)