Replace takes a key ("key") in a messagepack map ("raw") and replaces its value with the one provided and returns the new []byte. The returned []byte may point to the same memory as "raw". Replace makes no effort to evaluate the validity of the contents of 'val'. It may use up to the full capacity o
(key string, raw []byte, val []byte)
| 21 | // Replace returns 'nil' if the field doesn't exist or if the object in 'raw' |
| 22 | // is not a map. |
| 23 | func Replace(key string, raw []byte, val []byte) []byte { |
| 24 | start, end := locate(raw, key) |
| 25 | if start == end { |
| 26 | return nil |
| 27 | } |
| 28 | return replace(raw, start, end, val, true) |
| 29 | } |
| 30 | |
| 31 | // CopyReplace works similarly to Replace except that the returned |
| 32 | // byte slice does not point to the same memory as 'raw'. CopyReplace |
searching dependent graphs…