File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ type DynamoDBAttributeValue struct {
1818 dataType DynamoDBDataType
1919}
2020
21+ // This struct represents DynamoDBAttributeValue which doesn't
22+ // implement fmt.Stringer interface and safely `fmt.Sprintf`able
23+ type dynamoDbAttributeValue DynamoDBAttributeValue
24+
2125// Binary provides access to an attribute of type Binary.
2226// Method panics if the attribute is not of type Binary.
2327func (av DynamoDBAttributeValue ) Binary () []byte {
@@ -98,8 +102,13 @@ func (av DynamoDBAttributeValue) NumberSet() []string {
98102// String provides access to an attribute of type String.
99103// Method panics if the attribute is not of type String.
100104func (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 ))
103112}
104113
105114// StringSet provides access to an attribute of type String Set.
You can’t perform that action at this time.
0 commit comments