MCPcopy
hub / github.com/tinylib/msgp / ReadMapStrIntf

Method ReadMapStrIntf

msgp/read.go:1367–1394  ·  view source on GitHub ↗

ReadMapStrIntf reads a MessagePack map into a map[string]interface{}. (You must pass a non-nil map into the function.)

(mp map[string]any)

Source from the content-addressed store, hash-verified

1365// ReadMapStrIntf reads a MessagePack map into a map[string]interface{}.
1366// (You must pass a non-nil map into the function.)
1367func (m *Reader) ReadMapStrIntf(mp map[string]any) (err error) {
1368 var sz uint32
1369 sz, err = m.ReadMapHeader()
1370 if err != nil {
1371 return
1372 }
1373 for key := range mp {
1374 delete(mp, key)
1375 }
1376 if sz > m.GetMaxElements() {
1377 err = ErrLimitExceeded
1378 return
1379 }
1380 for i := uint32(0); i < sz; i++ {
1381 var key string
1382 var val any
1383 key, err = m.ReadString()
1384 if err != nil {
1385 return
1386 }
1387 val, err = m.ReadIntf()
1388 if err != nil {
1389 return
1390 }
1391 mp[key] = val
1392 }
1393 return
1394}
1395
1396// ReadTimeUTC reads a time.Time object from the reader.
1397// The returned time's location will be set to UTC.

Callers 3

TestReadIntfRecursionFunction · 0.95
FuzzReaderFunction · 0.95
ReadIntfMethod · 0.95

Calls 4

ReadMapHeaderMethod · 0.95
GetMaxElementsMethod · 0.95
ReadStringMethod · 0.95
ReadIntfMethod · 0.95

Tested by 2

TestReadIntfRecursionFunction · 0.76
FuzzReaderFunction · 0.76