Unmarshal parses the protocol buffer representation in buf and places the decoded result in pb. If the struct underlying pb does not match the data in buf, the results can be unpredictable. Unmarshal resets pb before starting to unmarshal, so any existing data in pb is always removed. Use Unmarsha
(buf []byte, pb Message)
| 332 | // existing data in pb is always removed. Use UnmarshalMerge |
| 333 | // to preserve and append to existing data. |
| 334 | func Unmarshal(buf []byte, pb Message) error { |
| 335 | pb.Reset() |
| 336 | if u, ok := pb.(newUnmarshaler); ok { |
| 337 | return u.XXX_Unmarshal(buf) |
| 338 | } |
| 339 | if u, ok := pb.(Unmarshaler); ok { |
| 340 | return u.Unmarshal(buf) |
| 341 | } |
| 342 | return NewBuffer(buf).Unmarshal(pb) |
| 343 | } |
| 344 | |
| 345 | // UnmarshalMerge parses the protocol buffer representation in buf and |
| 346 | // writes the decoded result to pb. If the struct underlying pb does not match |
searching dependent graphs…