github.com/aavshr/aws-sdk-go@v1.41.3/example/service/dynamodb/scanItems/README.md (about) 1 # Example 2 3 `scanItems` is an example how to use Amazon DynamoDB's Scan API operation with the SDK's `dynamodbattributes.UnmarshalListOfMaps` to unmarshal the Scan response's `Items` `[]map[string]*dynamodb.AttributeValue` field. This unmarshaler can be used with all `[]map[string]*dynamodb.AttributeValue` type fields. 4 5 ## Go Type 6 7 The `Item` time will be used by the example to unmarshal the DynamoDB table's items to. 8 9 ```go 10 type Item struct { 11 Key int 12 Desc string 13 Data map[string]interface{} 14 } 15 ``` 16 Use Go tags to define what the name is of the attribute in your DynamoDB table. See [AWS SDK for Go API Reference: Marshal](https://docs.aws.amazon.com/sdk-for-go/api/service/dynamodb/dynamodbattribute/#Marshal) for more information. 17 18 In DynamoDB the structure of the item to be returned will be: 19 ```json 20 { 21 "Data": { 22 "Value 1": "abc", 23 "Value 2": 1234567890 24 }, 25 "Desc": "First ddb item", 26 "Key": 1 27 } 28 ``` 29 30 ## Usage 31 32 `go run -tags example scanItems.go -table "<table_name>" -region "<optional_region>"` 33 34 ## Output 35 36 ``` 37 0: Key: 123, Desc: An item in the DynamoDB table 38 Num Data Values: 0 39 1: Key: 2, Desc: Second ddb item 40 Num Data Values: 2 41 - "A Field": 123 42 - "Another Field": abc 43 2: Key: 1, Desc: First ddb item 44 Num Data Values: 2 45 - "Value 1": abc 46 - "Value 2": 1234567890 47 ```