File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ type DynamoDBAttributeValue struct {
18
18
dataType DynamoDBDataType
19
19
}
20
20
21
+ // This struct represents DynamoDBAttributeValue which doesn't
22
+ // implement fmt.Stringer interface and safely `fmt.Sprintf`able
23
+ type dynamoDbAttributeValue DynamoDBAttributeValue
24
+
21
25
// Binary provides access to an attribute of type Binary.
22
26
// Method panics if the attribute is not of type Binary.
23
27
func (av DynamoDBAttributeValue ) Binary () []byte {
@@ -98,8 +102,13 @@ func (av DynamoDBAttributeValue) NumberSet() []string {
98
102
// String provides access to an attribute of type String.
99
103
// Method panics if the attribute is not of type String.
100
104
func (av DynamoDBAttributeValue ) String () string {
101
- av .ensureType (DataTypeString )
102
- return av .value .(string )
105
+ if av .dataType == DataTypeString {
106
+ return av .value .(string )
107
+ }
108
+ // If dataType is not DataTypeString during fmt.Sprintf("%#v", ...)
109
+ // compiler confuses with fmt.Stringer interface and panics
110
+ // instead of printing the struct.
111
+ return fmt .Sprintf ("%v" , dynamoDbAttributeValue (av ))
103
112
}
104
113
105
114
// StringSet provides access to an attribute of type String Set.
You can’t perform that action at this time.
0 commit comments