cdcEncode returns nil if the input is nil, otherwise returns proto.Marshal( Value{Value: item})
(item interface{})
| 9 | // cdcEncode returns nil if the input is nil, otherwise returns |
| 10 | // proto.Marshal(<type>Value{Value: item}) |
| 11 | func cdcEncode(item interface{}) []byte { |
| 12 | if item != nil && !isTypedNil(item) && !isEmpty(item) { |
| 13 | switch item := item.(type) { |
| 14 | case string: |
| 15 | i := gogotypes.StringValue{ |
| 16 | Value: item, |
| 17 | } |
| 18 | bz, err := i.Marshal() |
| 19 | if err != nil { |
| 20 | return nil |
| 21 | } |
| 22 | return bz |
| 23 | case int64: |
| 24 | i := gogotypes.Int64Value{ |
| 25 | Value: item, |
| 26 | } |
| 27 | bz, err := i.Marshal() |
| 28 | if err != nil { |
| 29 | return nil |
| 30 | } |
| 31 | return bz |
| 32 | case bytes.HexBytes: |
| 33 | i := gogotypes.BytesValue{ |
| 34 | Value: item, |
| 35 | } |
| 36 | bz, err := i.Marshal() |
| 37 | if err != nil { |
| 38 | return nil |
| 39 | } |
| 40 | return bz |
| 41 | default: |
| 42 | return nil |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | return nil |
| 47 | } |
searching dependent graphs…