Marshal returns the gob encoding of "value".
(value interface{})
| 90 | |
| 91 | // Marshal returns the gob encoding of "value". |
| 92 | func (GobTranscoder) Marshal(value interface{}) ([]byte, error) { |
| 93 | var ( |
| 94 | w = new(bytes.Buffer) |
| 95 | enc = gob.NewEncoder(w) |
| 96 | err error |
| 97 | ) |
| 98 | |
| 99 | if v, ok := value.(reflect.Value); ok { |
| 100 | err = enc.EncodeValue(v) |
| 101 | } else { |
| 102 | err = enc.Encode(&value) |
| 103 | } |
| 104 | |
| 105 | if err != nil { |
| 106 | return nil, err |
| 107 | } |
| 108 | |
| 109 | return w.Bytes(), nil |
| 110 | } |
| 111 | |
| 112 | // Unmarshal parses the gob-encoded data "b" and stores the result |
| 113 | // in the value pointed to by "outPtr". |