本文整理匯總了Golang中github.com/aws/aws-sdk-go/service/dynamodb.AttributeValue.M方法的典型用法代碼示例。如果您正苦於以下問題:Golang AttributeValue.M方法的具體用法?Golang AttributeValue.M怎麽用?Golang AttributeValue.M使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/aws/aws-sdk-go/service/dynamodb.AttributeValue
的用法示例。
在下文中一共展示了AttributeValue.M方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: encodeMap
func (e *Encoder) encodeMap(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error {
av.M = map[string]*dynamodb.AttributeValue{}
for _, key := range v.MapKeys() {
keyName := fmt.Sprint(key.Interface())
if keyName == "" {
return &InvalidMarshalError{msg: "map key cannot be empty"}
}
elemVal := v.MapIndex(key)
elem := &dynamodb.AttributeValue{}
err := e.encode(elem, elemVal, tag{})
skip, err := keepOrOmitEmpty(fieldTag.OmitEmptyElem, elem, err)
if err != nil {
return err
} else if skip {
continue
}
av.M[keyName] = elem
}
if len(av.M) == 0 {
encodeNull(av)
}
return nil
}
示例2: encodeStruct
func (e *Encoder) encodeStruct(av *dynamodb.AttributeValue, v reflect.Value) error {
// To maintain backwards compatibility with ConvertTo family of methods which
// converted time.Time structs to strings
if t, ok := v.Interface().(time.Time); ok {
s := t.Format(time.RFC3339Nano)
av.S = &s
return nil
}
av.M = map[string]*dynamodb.AttributeValue{}
fields := unionStructFields(v.Type(), e.MarshalOptions)
for _, f := range fields {
if f.Name == "" {
return &InvalidMarshalError{msg: "map key cannot be empty"}
}
fv := v.FieldByIndex(f.Index)
elem := &dynamodb.AttributeValue{}
err := e.encode(elem, fv, f.tag)
skip, err := keepOrOmitEmpty(f.OmitEmpty, elem, err)
if err != nil {
return err
} else if skip {
continue
}
av.M[f.Name] = elem
}
if len(av.M) == 0 {
encodeNull(av)
}
return nil
}
示例3: encodeStruct
func (e *Encoder) encodeStruct(av *dynamodb.AttributeValue, v reflect.Value) error {
av.M = map[string]*dynamodb.AttributeValue{}
fields := unionStructFields(v.Type(), e.MarshalOptions)
for _, f := range fields {
if f.Name == "" {
return &InvalidMarshalError{msg: "map key cannot be empty"}
}
fv := v.FieldByIndex(f.Index)
elem := &dynamodb.AttributeValue{}
err := e.encode(elem, fv, f.tag)
skip, err := keepOrOmitEmpty(f.OmitEmpty, elem, err)
if err != nil {
return err
} else if skip {
continue
}
av.M[f.Name] = elem
}
if len(av.M) == 0 {
encodeNull(av)
}
return nil
}
示例4: MarshalDynamoDBAttributeValue
func (m *marshalMarshaler) MarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) error {
av.M = map[string]*dynamodb.AttributeValue{
"abc": {S: &m.Value},
"def": {N: aws.String(fmt.Sprintf("%d", m.Value2))},
"ghi": {BOOL: &m.Value3},
}
return nil
}