• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang msgp.ReadArrayHeaderBytes函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/tinylib/msgp/msgp.ReadArrayHeaderBytes函数的典型用法代码示例。如果您正苦于以下问题:Golang ReadArrayHeaderBytes函数的具体用法?Golang ReadArrayHeaderBytes怎么用?Golang ReadArrayHeaderBytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ReadArrayHeaderBytes函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *KVs) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var xsz uint32
	xsz, bts, err = msgp.ReadArrayHeaderBytes(bts)
	if err != nil {
		return
	}
	if cap((*z)) >= int(xsz) {
		(*z) = (*z)[:xsz]
	} else {
		(*z) = make(KVs, xsz)
	}
	for cua := range *z {
		var asz uint32
		asz, bts, err = msgp.ReadArrayHeaderBytes(bts)
		if err != nil {
			return
		}
		if asz != 2 {
			err = msgp.ArrayError{Wanted: 2, Got: asz}
			return
		}
		for xhx := range (*z)[cua] {
			{
				var tmp []byte
				tmp, bts, err = msgp.ReadBytesBytes(bts, []byte((*z)[cua][xhx]))
				(*z)[cua][xhx] = Binary(tmp)
			}
			if err != nil {
				return
			}
		}
	}
	o = bts
	return
}
开发者ID:tartavull,项目名称:dvid,代码行数:36,代码来源:msgpack_gen.go


示例2: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *Forward) UnmarshalMsg(bts []byte) (o []byte, err error) {
	{
		var ssz uint32
		ssz, bts, err = msgp.ReadArrayHeaderBytes(bts)
		if err != nil {
			return
		}
		if ssz != 3 {
			err = msgp.ArrayError{Wanted: 3, Got: ssz}
			return
		}
	}
	z.Tag, bts, err = msgp.ReadStringBytes(bts)
	if err != nil {
		return
	}
	var xsz uint32
	xsz, bts, err = msgp.ReadArrayHeaderBytes(bts)
	if err != nil {
		return
	}
	if cap(z.Entries) >= int(xsz) {
		z.Entries = z.Entries[:xsz]
	} else {
		z.Entries = make([]Entry, xsz)
	}
	for xvk := range z.Entries {
		{
			var ssz uint32
			ssz, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				return
			}
			if ssz != 2 {
				err = msgp.ArrayError{Wanted: 2, Got: ssz}
				return
			}
		}
		z.Entries[xvk].Time, bts, err = msgp.ReadInt64Bytes(bts)
		if err != nil {
			return
		}
		z.Entries[xvk].Record, bts, err = msgp.ReadIntfBytes(bts)
		if err != nil {
			return
		}
	}
	z.Option, bts, err = msgp.ReadIntfBytes(bts)
	if err != nil {
		return
	}
	o = bts
	return
}
开发者ID:CadeLaRen,项目名称:docker-3,代码行数:55,代码来源:proto_gen.go


示例3: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *MetricDataArray) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var xsz uint32
	xsz, bts, err = msgp.ReadArrayHeaderBytes(bts)
	if err != nil {
		return
	}
	if cap((*z)) >= int(xsz) {
		(*z) = (*z)[:xsz]
	} else {
		(*z) = make(MetricDataArray, xsz)
	}
	for ajw := range *z {
		if msgp.IsNil(bts) {
			bts, err = msgp.ReadNilBytes(bts)
			if err != nil {
				return
			}
			(*z)[ajw] = nil
		} else {
			if (*z)[ajw] == nil {
				(*z)[ajw] = new(MetricData)
			}
			bts, err = (*z)[ajw].UnmarshalMsg(bts)
			if err != nil {
				return
			}
		}
	}
	o = bts
	return
}
开发者ID:aglagla,项目名称:raintank-metric,代码行数:32,代码来源:metric_gen.go


示例4: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *Keys) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var xsz uint32
	xsz, bts, err = msgp.ReadArrayHeaderBytes(bts)
	if err != nil {
		return
	}
	if cap((*z)) >= int(xsz) {
		(*z) = (*z)[:xsz]
	} else {
		(*z) = make(Keys, xsz)
	}
	for bzg := range *z {
		if msgp.IsNil(bts) {
			bts, err = msgp.ReadNilBytes(bts)
			if err != nil {
				return
			}
			(*z)[bzg] = nil
		} else {
			if (*z)[bzg] == nil {
				(*z)[bzg] = new(Key)
			}
			bts, err = (*z)[bzg].UnmarshalMsg(bts)
			if err != nil {
				return
			}
		}
	}
	o = bts
	return
}
开发者ID:jim3mar,项目名称:go-datastructures,代码行数:32,代码来源:node_gen.go


示例5: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *Snap) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "LowestTrackableValue":
			z.LowestTrackableValue, bts, err = msgp.ReadInt64Bytes(bts)
			if err != nil {
				return
			}
		case "HighestTrackableValue":
			z.HighestTrackableValue, bts, err = msgp.ReadInt64Bytes(bts)
			if err != nil {
				return
			}
		case "SignificantFigures":
			z.SignificantFigures, bts, err = msgp.ReadInt64Bytes(bts)
			if err != nil {
				return
			}
		case "Counts":
			var xsz uint32
			xsz, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				return
			}
			if cap(z.Counts) >= int(xsz) {
				z.Counts = z.Counts[:xsz]
			} else {
				z.Counts = make([]int64, xsz)
			}
			for xvk := range z.Counts {
				z.Counts[xvk], bts, err = msgp.ReadInt64Bytes(bts)
				if err != nil {
					return
				}
			}
		default:
			bts, err = msgp.Skip(bts)
			if err != nil {
				return
			}
		}
	}
	o = bts
	return
}
开发者ID:Dieterbe,项目名称:hdrhistogramtest,代码行数:58,代码来源:test_gen.go


示例6: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *ColorGroup) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "id":
			z.Id, bts, err = msgp.ReadIntBytes(bts)
			if err != nil {
				return
			}
		case "name":
			z.Name, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				return
			}
		case "colors":
			var xsz uint32
			xsz, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				return
			}
			if cap(z.Colors) >= int(xsz) {
				z.Colors = z.Colors[:xsz]
			} else {
				z.Colors = make([]string, xsz)
			}
			for xvk := range z.Colors {
				z.Colors[xvk], bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					return
				}
			}
		default:
			bts, err = msgp.Skip(bts)
			if err != nil {
				return
			}
		}
	}
	o = bts
	return
}
开发者ID:jameswei,项目名称:gosercomp,代码行数:53,代码来源:msgp_gen.go


示例7: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *InterfaceT) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field
	var zpks uint32
	zpks, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		return
	}
	for zpks > 0 {
		zpks--
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "Methods":
			var zjfb uint32
			zjfb, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				return
			}
			if cap(z.Methods) >= int(zjfb) {
				z.Methods = (z.Methods)[:zjfb]
			} else {
				z.Methods = make([]MethodT, zjfb)
			}
			for zxhx := range z.Methods {
				bts, err = z.Methods[zxhx].UnmarshalMsg(bts)
				if err != nil {
					return
				}
			}
		case "Deprecated":
			z.Deprecated, bts, err = msgp.ReadBoolBytes(bts)
			if err != nil {
				return
			}
		case "Comment":
			z.Comment, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				return
			}
		default:
			bts, err = msgp.Skip(bts)
			if err != nil {
				return
			}
		}
	}
	o = bts
	return
}
开发者ID:glycerine,项目名称:zebra,代码行数:53,代码来源:zebra_gen.go


示例8: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *bitmapContainer) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field
	var zcmr uint32
	zcmr, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		return
	}
	for zcmr > 0 {
		zcmr--
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "cardinality":
			z.cardinality, bts, err = msgp.ReadIntBytes(bts)
			if err != nil {
				return
			}
		case "bitmap":
			var zajw uint32
			zajw, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				return
			}
			if cap(z.bitmap) >= int(zajw) {
				z.bitmap = (z.bitmap)[:zajw]
			} else {
				z.bitmap = make([]uint64, zajw)
			}
			for zxvk := range z.bitmap {
				z.bitmap[zxvk], bts, err = msgp.ReadUint64Bytes(bts)
				if err != nil {
					return
				}
			}
		default:
			bts, err = msgp.Skip(bts)
			if err != nil {
				return
			}
		}
	}
	o = bts
	return
}
开发者ID:RoaringBitmap,项目名称:roaring,代码行数:48,代码来源:bitmapcontainer_gen.go


示例9: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *arrayContainer) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field
	var zcmr uint32
	zcmr, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		return
	}
	for zcmr > 0 {
		zcmr--
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "content":
			var zajw uint32
			zajw, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				return
			}
			if cap(z.content) >= int(zajw) {
				z.content = (z.content)[:zajw]
			} else {
				z.content = make([]uint16, zajw)
			}
			for zxvk := range z.content {
				z.content[zxvk], bts, err = msgp.ReadUint16Bytes(bts)
				if err != nil {
					return
				}
			}
		default:
			bts, err = msgp.Skip(bts)
			if err != nil {
				return
			}
		}
	}
	o = bts
	return
}
开发者ID:RoaringBitmap,项目名称:roaring,代码行数:43,代码来源:arraycontainer_gen.go


示例10: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *uint32Slice) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var zgmo uint32
	zgmo, bts, err = msgp.ReadArrayHeaderBytes(bts)
	if err != nil {
		return
	}
	if cap((*z)) >= int(zgmo) {
		(*z) = (*z)[:zgmo]
	} else {
		(*z) = make(uint32Slice, zgmo)
	}
	for zrfe := range *z {
		(*z)[zrfe], bts, err = msgp.ReadUint32Bytes(bts)
		if err != nil {
			return
		}
	}
	o = bts
	return
}
开发者ID:RoaringBitmap,项目名称:roaring,代码行数:21,代码来源:rle_gen.go


示例11: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *DocumentList) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var xsz uint32
	xsz, bts, err = msgp.ReadArrayHeaderBytes(bts)
	if err != nil {
		return
	}
	if cap((*z)) >= int(xsz) {
		(*z) = (*z)[:xsz]
	} else {
		(*z) = make(DocumentList, xsz)
	}
	for cmr := range *z {
		{
			var tmp uint
			tmp, bts, err = msgp.ReadUintBytes(bts)
			(*z)[cmr] = DocumentID(tmp)
		}
		if err != nil {
			return
		}
	}
	o = bts
	return
}
开发者ID:JustinAzoff,项目名称:flow-indexer,代码行数:25,代码来源:documentlist_msgp_gen.go


示例12: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *roaringArray) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field
	var zrsw uint32
	zrsw, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		return
	}
	for zrsw > 0 {
		zrsw--
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "keys":
			var zxpk uint32
			zxpk, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				return
			}
			if cap(z.keys) >= int(zxpk) {
				z.keys = (z.keys)[:zxpk]
			} else {
				z.keys = make([]uint16, zxpk)
			}
			for zhct := range z.keys {
				z.keys[zhct], bts, err = msgp.ReadUint16Bytes(bts)
				if err != nil {
					return
				}
			}
		case "needCopyOnWrite":
			var zdnj uint32
			zdnj, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				return
			}
			if cap(z.needCopyOnWrite) >= int(zdnj) {
				z.needCopyOnWrite = (z.needCopyOnWrite)[:zdnj]
			} else {
				z.needCopyOnWrite = make([]bool, zdnj)
			}
			for zcua := range z.needCopyOnWrite {
				z.needCopyOnWrite[zcua], bts, err = msgp.ReadBoolBytes(bts)
				if err != nil {
					return
				}
			}
		case "copyOnWrite":
			z.copyOnWrite, bts, err = msgp.ReadBoolBytes(bts)
			if err != nil {
				return
			}
		case "conserz":
			var zobc uint32
			zobc, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				return
			}
			if cap(z.conserz) >= int(zobc) {
				z.conserz = (z.conserz)[:zobc]
			} else {
				z.conserz = make([]containerSerz, zobc)
			}
			for zxhx := range z.conserz {
				var zsnv uint32
				zsnv, bts, err = msgp.ReadMapHeaderBytes(bts)
				if err != nil {
					return
				}
				for zsnv > 0 {
					zsnv--
					field, bts, err = msgp.ReadMapKeyZC(bts)
					if err != nil {
						return
					}
					switch msgp.UnsafeString(field) {
					case "t":
						{
							var zkgt uint8
							zkgt, bts, err = msgp.ReadUint8Bytes(bts)
							z.conserz[zxhx].t = contype(zkgt)
						}
						if err != nil {
							return
						}
					case "r":
						bts, err = z.conserz[zxhx].r.UnmarshalMsg(bts)
						if err != nil {
							return
						}
					default:
						bts, err = msgp.Skip(bts)
						if err != nil {
							return
						}
					}
				}
//.........这里部分代码省略.........
开发者ID:RoaringBitmap,项目名称:roaring,代码行数:101,代码来源:roaringarray_gen.go


示例13: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *ServerResponse) UnmarshalMsg(bts []byte) (o []byte, err error) {
	{
		var ssz uint32
		ssz, bts, err = msgp.ReadArrayHeaderBytes(bts)
		if err != nil {
			return
		}
		if ssz != 3 {
			err = msgp.ArrayError{Wanted: 3, Got: ssz}
			return
		}
	}
	if msgp.IsNil(bts) {
		bts, err = msgp.ReadNilBytes(bts)
		if err != nil {
			return
		}
		z.Header = nil
	} else {
		if z.Header == nil {
			z.Header = new(EventHeader)
		}
		var field []byte
		_ = field
		var isz uint32
		isz, bts, err = msgp.ReadMapHeaderBytes(bts)
		if err != nil {
			return
		}
		for isz > 0 {
			isz--
			field, bts, err = msgp.ReadMapKeyZC(bts)
			if err != nil {
				return
			}
			switch msgp.UnsafeString(field) {
			case "message_id":
				z.Header.Id, bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					return
				}
			case "v":
				z.Header.Version, bts, err = msgp.ReadIntBytes(bts)
				if err != nil {
					return
				}
			case "response_to":
				z.Header.ResponseTo, bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					return
				}
			default:
				bts, err = msgp.Skip(bts)
				if err != nil {
					return
				}
			}
		}
	}
	z.Name, bts, err = msgp.ReadStringBytes(bts)
	if err != nil {
		return
	}
	var xsz uint32
	xsz, bts, err = msgp.ReadArrayHeaderBytes(bts)
	if err != nil {
		return
	}
	if cap(z.Params) >= int(xsz) {
		z.Params = z.Params[:xsz]
	} else {
		z.Params = make([]interface{}, xsz)
	}
	for bzg := range z.Params {
		z.Params[bzg], bts, err = msgp.ReadIntfBytes(bts)
		if err != nil {
			return
		}
	}
	o = bts
	return
}
开发者ID:mengzhuo,项目名称:zerorpc-golang,代码行数:83,代码来源:protocal_gen.go


示例14: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *Car) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field
	var lqf uint32
	lqf, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		return
	}
	for lqf > 0 {
		lqf--
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "CarId":
			z.CarId, bts, err = msgp.ReadIntBytes(bts)
			if err != nil {
				return
			}
		case "CarName":
			z.CarName, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				return
			}
		case "Attributes":
			var daf uint32
			daf, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				return
			}
			if cap(z.Attributes) >= int(daf) {
				z.Attributes = z.Attributes[:daf]
			} else {
				z.Attributes = make([]Attribute, daf)
			}
			for bai := range z.Attributes {
				var pks uint32
				pks, bts, err = msgp.ReadMapHeaderBytes(bts)
				if err != nil {
					return
				}
				for pks > 0 {
					pks--
					field, bts, err = msgp.ReadMapKeyZC(bts)
					if err != nil {
						return
					}
					switch msgp.UnsafeString(field) {
					case "Id":
						z.Attributes[bai].Id, bts, err = msgp.ReadIntBytes(bts)
						if err != nil {
							return
						}
					case "Name":
						z.Attributes[bai].Name, bts, err = msgp.ReadStringBytes(bts)
						if err != nil {
							return
						}
					case "Value":
						z.Attributes[bai].Value, bts, err = msgp.ReadStringBytes(bts)
						if err != nil {
							return
						}
					default:
						bts, err = msgp.Skip(bts)
						if err != nil {
							return
						}
					}
				}
			}
		case "FlagMap":
			var jfb uint32
			jfb, bts, err = msgp.ReadMapHeaderBytes(bts)
			if err != nil {
				return
			}
			if z.FlagMap == nil && jfb > 0 {
				z.FlagMap = make(map[string]string, jfb)
			} else if len(z.FlagMap) > 0 {
				for key, _ := range z.FlagMap {
					delete(z.FlagMap, key)
				}
			}
			for jfb > 0 {
				var cmr string
				var ajw string
				jfb--
				cmr, bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					return
				}
				ajw, bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					return
				}
				z.FlagMap[cmr] = ajw
			}
//.........这里部分代码省略.........
开发者ID:darciopacifico,项目名称:enablecache,代码行数:101,代码来源:schema_gen.go


示例15: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *Event) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "id":
			z.Id, bts, err = msgp.ReadIntBytes(bts)
			if err != nil {
				return
			}
		case "user":
			var isz uint32
			isz, bts, err = msgp.ReadMapHeaderBytes(bts)
			if err != nil {
				return
			}
			for isz > 0 {
				isz--
				field, bts, err = msgp.ReadMapKeyZC(bts)
				if err != nil {
					return
				}
				switch msgp.UnsafeString(field) {
				case "first":
					z.User.First, bts, err = msgp.ReadStringBytes(bts)
					if err != nil {
						return
					}
				case "last":
					z.User.Last, bts, err = msgp.ReadStringBytes(bts)
					if err != nil {
						return
					}
				default:
					bts, err = msgp.Skip(bts)
					if err != nil {
						return
					}
				}
			}
		case "flight":
			z.Flight, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				return
			}
		case "pilot":
			var xsz uint32
			xsz, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				return
			}
			if cap(z.Pilot) >= int(xsz) {
				z.Pilot = z.Pilot[:xsz]
			} else {
				z.Pilot = make([]string, xsz)
			}
			for xvk := range z.Pilot {
				z.Pilot[xvk], bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					return
				}
			}
		default:
			bts, err = msgp.Skip(bts)
			if err != nil {
				return
			}
		}
	}
	o = bts
	return
}
开发者ID:glycerine,项目名称:zygomys,代码行数:83,代码来源:demo_go_structs_gen.go


示例16: UnmarshalMsg

// UnmarshalMsg implements msgp.Unmarshaler
func (z *Group) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "Name":
			z.Name, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				return
			}
		case "Members":
			var xsz uint32
			xsz, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				return
			}
			if cap(z.Members) >= int(xsz) {
				z.Members = z.Members[:xsz]
			} else {
				z.Members = make([]Person, xsz)
			}
			for xvk := range z.Members {
				var isz uint32
				isz, bts, err = msgp.ReadMapHeaderBytes(bts)
				if err != nil {
					return
				}
				for isz > 0 {
					isz--
					field, bts, err = msgp.ReadMapKeyZC(bts)
					if err != nil {
						return
					}
					switch msgp.UnsafeString(field) {
					case "Name":
						z.Members[xvk].Name, bts, err = msgp.ReadStringBytes(bts)
						if err != nil {
							return
						}
					case "Age":
						z.Members[xvk].Age, bts, err = msgp.ReadUint8Bytes(bts)
						if err != nil {
							return
						}
					case "Height":
						z.Members[xvk].Height, bts, err = msgp.ReadFloat64Bytes(bts)
						if err != nil {
							return
						}
					default:
						bts, err = msgp.Skip(bts)
						if err != nil {
							return
						}
					}
				}
			}
		default:
			bts, err = msgp.Skip(bts)
			if err != nil {
				return
			}
		}
	}
	o = bts
	return
}
开发者ID:andyleap,项目名称:gencode,代码行数:78,代码来源:test.schema.gen_gen.go



注:本文中的github.com/tinylib/msgp/msgp.ReadArrayHeaderBytes函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang msgp.ReadMapHeaderBytes函数代码示例发布时间:2022-05-28
下一篇:
Golang msgp.NewWriter函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap