當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Writer.WriteArrayHeader方法代碼示例

本文整理匯總了Golang中github.com/tinylib/msgp/msgp.Writer.WriteArrayHeader方法的典型用法代碼示例。如果您正苦於以下問題:Golang Writer.WriteArrayHeader方法的具體用法?Golang Writer.WriteArrayHeader怎麽用?Golang Writer.WriteArrayHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/tinylib/msgp/msgp.Writer的用法示例。


在下文中一共展示了Writer.WriteArrayHeader方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z *bitmapContainer) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 2
	// write "cardinality"
	err = en.Append(0x82, 0xab, 0x63, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.cardinality)
	if err != nil {
		return
	}
	// write "bitmap"
	err = en.Append(0xa6, 0x62, 0x69, 0x74, 0x6d, 0x61, 0x70)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.bitmap)))
	if err != nil {
		return
	}
	for zxvk := range z.bitmap {
		err = en.WriteUint64(z.bitmap[zxvk])
		if err != nil {
			return
		}
	}
	return
}
開發者ID:RoaringBitmap,項目名稱:roaring,代碼行數:29,代碼來源:bitmapcontainer_gen.go

示例2: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z *Event) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 4
	// write "id"
	err = en.Append(0x84, 0xa2, 0x69, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.Id)
	if err != nil {
		return
	}
	// write "user"
	// map header, size 2
	// write "first"
	err = en.Append(0xa4, 0x75, 0x73, 0x65, 0x72, 0x82, 0xa5, 0x66, 0x69, 0x72, 0x73, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteString(z.User.First)
	if err != nil {
		return
	}
	// write "last"
	err = en.Append(0xa4, 0x6c, 0x61, 0x73, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteString(z.User.Last)
	if err != nil {
		return
	}
	// write "flight"
	err = en.Append(0xa6, 0x66, 0x6c, 0x69, 0x67, 0x68, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Flight)
	if err != nil {
		return
	}
	// write "pilot"
	err = en.Append(0xa5, 0x70, 0x69, 0x6c, 0x6f, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.Pilot)))
	if err != nil {
		return
	}
	for xvk := range z.Pilot {
		err = en.WriteString(z.Pilot[xvk])
		if err != nil {
			return
		}
	}
	return
}
開發者ID:glycerine,項目名稱:zygomys,代碼行數:58,代碼來源:demo_go_structs_gen.go

示例3: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z *ServerResponse) EncodeMsg(en *msgp.Writer) (err error) {
	// array header, size 3
	err = en.Append(0x93)
	if err != nil {
		return err
	}
	if z.Header == nil {
		err = en.WriteNil()
		if err != nil {
			return
		}
	} else {
		// map header, size 3
		// write "message_id"
		err = en.Append(0x83, 0xaa, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x64)
		if err != nil {
			return err
		}
		err = en.WriteString(z.Header.Id)
		if err != nil {
			return
		}
		// write "v"
		err = en.Append(0xa1, 0x76)
		if err != nil {
			return err
		}
		err = en.WriteInt(z.Header.Version)
		if err != nil {
			return
		}
		// write "response_to"
		err = en.Append(0xab, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x74, 0x6f)
		if err != nil {
			return err
		}
		err = en.WriteString(z.Header.ResponseTo)
		if err != nil {
			return
		}
	}
	err = en.WriteString(z.Name)
	if err != nil {
		return
	}
	err = en.WriteArrayHeader(uint32(len(z.Params)))
	if err != nil {
		return
	}
	for bzg := range z.Params {
		err = en.WriteIntf(z.Params[bzg])
		if err != nil {
			return
		}
	}
	return
}
開發者ID:mengzhuo,項目名稱:zerorpc-golang,代碼行數:58,代碼來源:protocal_gen.go

示例4: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z *StructT) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 5
	// write "StructId"
	err = en.Append(0x85, 0xa8, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x49, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteInt64(z.StructId)
	if err != nil {
		return
	}
	// write "StructName"
	err = en.Append(0xaa, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteString(z.StructName)
	if err != nil {
		return
	}
	// write "Fields"
	err = en.Append(0xa6, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.Fields)))
	if err != nil {
		return
	}
	for zyzr := range z.Fields {
		err = z.Fields[zyzr].EncodeMsg(en)
		if err != nil {
			return
		}
	}
	// write "Deprecated"
	err = en.Append(0xaa, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteBool(z.Deprecated)
	if err != nil {
		return
	}
	// write "Comment"
	err = en.Append(0xa7, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Comment)
	if err != nil {
		return
	}
	return
}
開發者ID:glycerine,項目名稱:zebra,代碼行數:56,代碼來源:zebra_gen.go

示例5: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z *Group) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 2
	// write "Name"
	err = en.Append(0x82, 0xa4, 0x4e, 0x61, 0x6d, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Name)
	if err != nil {
		return
	}
	// write "Members"
	err = en.Append(0xa7, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.Members)))
	if err != nil {
		return
	}
	for xvk := range z.Members {
		// map header, size 3
		// write "Name"
		err = en.Append(0x83, 0xa4, 0x4e, 0x61, 0x6d, 0x65)
		if err != nil {
			return err
		}
		err = en.WriteString(z.Members[xvk].Name)
		if err != nil {
			return
		}
		// write "Age"
		err = en.Append(0xa3, 0x41, 0x67, 0x65)
		if err != nil {
			return err
		}
		err = en.WriteUint8(z.Members[xvk].Age)
		if err != nil {
			return
		}
		// write "Height"
		err = en.Append(0xa6, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74)
		if err != nil {
			return err
		}
		err = en.WriteFloat64(z.Members[xvk].Height)
		if err != nil {
			return
		}
	}
	return
}
開發者ID:andyleap,項目名稱:gencode,代碼行數:53,代碼來源:test.schema.gen_gen.go

示例6: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z uint32Slice) EncodeMsg(en *msgp.Writer) (err error) {
	err = en.WriteArrayHeader(uint32(len(z)))
	if err != nil {
		return
	}
	for zzpf := range z {
		err = en.WriteUint32(z[zzpf])
		if err != nil {
			return
		}
	}
	return
}
開發者ID:RoaringBitmap,項目名稱:roaring,代碼行數:14,代碼來源:rle_gen.go

示例7: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z Ks) EncodeMsg(en *msgp.Writer) (err error) {
	err = en.WriteArrayHeader(uint32(len(z)))
	if err != nil {
		return
	}
	for cxo := range z {
		err = en.WriteBytes([]byte(z[cxo]))
		if err != nil {
			return
		}
	}
	return
}
開發者ID:tartavull,項目名稱:dvid,代碼行數:14,代碼來源:msgpack_gen.go

示例8: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z DocumentList) EncodeMsg(en *msgp.Writer) (err error) {
	err = en.WriteArrayHeader(uint32(len(z)))
	if err != nil {
		return
	}
	for bai := range z {
		err = en.WriteUint(uint(z[bai]))
		if err != nil {
			return
		}
	}
	return
}
開發者ID:JustinAzoff,項目名稱:flow-indexer,代碼行數:14,代碼來源:documentlist_msgp_gen.go

示例9: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z Entry) EncodeMsg(en *msgp.Writer) (err error) {
	err = en.WriteArrayHeader(2)
	if err != nil {
		return
	}
	err = en.WriteInt64(z.Time)
	if err != nil {
		return
	}
	err = en.WriteIntf(z.Record)
	if err != nil {
		return
	}
	return
}
開發者ID:CadeLaRen,項目名稱:docker-3,代碼行數:16,代碼來源:proto_gen.go

示例10: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z *Snap) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 4
	// write "LowestTrackableValue"
	err = en.Append(0x84, 0xb4, 0x4c, 0x6f, 0x77, 0x65, 0x73, 0x74, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteInt64(z.LowestTrackableValue)
	if err != nil {
		return
	}
	// write "HighestTrackableValue"
	err = en.Append(0xb5, 0x48, 0x69, 0x67, 0x68, 0x65, 0x73, 0x74, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x61, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteInt64(z.HighestTrackableValue)
	if err != nil {
		return
	}
	// write "SignificantFigures"
	err = en.Append(0xb2, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x66, 0x69, 0x63, 0x61, 0x6e, 0x74, 0x46, 0x69, 0x67, 0x75, 0x72, 0x65, 0x73)
	if err != nil {
		return err
	}
	err = en.WriteInt64(z.SignificantFigures)
	if err != nil {
		return
	}
	// write "Counts"
	err = en.Append(0xa6, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x73)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.Counts)))
	if err != nil {
		return
	}
	for xvk := range z.Counts {
		err = en.WriteInt64(z.Counts[xvk])
		if err != nil {
			return
		}
	}
	return
}
開發者ID:Dieterbe,項目名稱:hdrhistogramtest,代碼行數:47,代碼來源:test_gen.go

示例11: EncodeMsg

func (r *Response) EncodeMsg(w *msgp.Writer) error {
	var bm msgp.Encodable

	if r.Body != nil {
		var ok bool
		bm, ok = r.Body.(msgp.Encodable)
		if !ok {
			return ErrNotEncodable
		}
	}

	var err error

	if err = w.WriteArrayHeader(ResponsePackSize); err != nil {
		return err
	}

	if err = w.WriteInt(ResponseType); err != nil {
		return err
	}

	if err = w.WriteUint32(r.ID); err != nil {
		return err
	}

	// No error.
	if r.Error == "" {
		if err = w.WriteNil(); err != nil {
			return err
		}

		if bm != nil {
			return msgp.Encode(w, bm)
		}
	} else {
		if err = w.WriteString(r.Error); err != nil {
			return err
		}
	}

	// Write nil body.
	return w.WriteNil()
}
開發者ID:micro,項目名稱:go-plugins,代碼行數:43,代碼來源:rpc.go

示例12: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z *arrayContainer) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 1
	// write "content"
	err = en.Append(0x81, 0xa7, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.content)))
	if err != nil {
		return
	}
	for zxvk := range z.content {
		err = en.WriteUint16(z.content[zxvk])
		if err != nil {
			return
		}
	}
	return
}
開發者ID:RoaringBitmap,項目名稱:roaring,代碼行數:20,代碼來源:arraycontainer_gen.go

示例13: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z MetricDataArray) EncodeMsg(en *msgp.Writer) (err error) {
	err = en.WriteArrayHeader(uint32(len(z)))
	if err != nil {
		return
	}
	for cmr := range z {
		if z[cmr] == nil {
			err = en.WriteNil()
			if err != nil {
				return
			}
		} else {
			err = z[cmr].EncodeMsg(en)
			if err != nil {
				return
			}
		}
	}
	return
}
開發者ID:aglagla,項目名稱:raintank-metric,代碼行數:21,代碼來源:metric_gen.go

示例14: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z *roaringArray) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 4
	// write "keys"
	err = en.Append(0x84, 0xa4, 0x6b, 0x65, 0x79, 0x73)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.keys)))
	if err != nil {
		return
	}
	for zhct := range z.keys {
		err = en.WriteUint16(z.keys[zhct])
		if err != nil {
			return
		}
	}
	// write "needCopyOnWrite"
	err = en.Append(0xaf, 0x6e, 0x65, 0x65, 0x64, 0x43, 0x6f, 0x70, 0x79, 0x4f, 0x6e, 0x57, 0x72, 0x69, 0x74, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.needCopyOnWrite)))
	if err != nil {
		return
	}
	for zcua := range z.needCopyOnWrite {
		err = en.WriteBool(z.needCopyOnWrite[zcua])
		if err != nil {
			return
		}
	}
	// write "copyOnWrite"
	err = en.Append(0xab, 0x63, 0x6f, 0x70, 0x79, 0x4f, 0x6e, 0x57, 0x72, 0x69, 0x74, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteBool(z.copyOnWrite)
	if err != nil {
		return
	}
	// write "conserz"
	err = en.Append(0xa7, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x72, 0x7a)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.conserz)))
	if err != nil {
		return
	}
	for zxhx := range z.conserz {
		// map header, size 2
		// write "t"
		err = en.Append(0x82, 0xa1, 0x74)
		if err != nil {
			return err
		}
		err = en.WriteUint8(uint8(z.conserz[zxhx].t))
		if err != nil {
			return
		}
		// write "r"
		err = en.Append(0xa1, 0x72)
		if err != nil {
			return err
		}
		err = z.conserz[zxhx].r.EncodeMsg(en)
		if err != nil {
			return
		}
	}
	return
}
開發者ID:RoaringBitmap,項目名稱:roaring,代碼行數:74,代碼來源:roaringarray_gen.go

示例15: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z *Car) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 5
	// write "CarId"
	err = en.Append(0x85, 0xa5, 0x43, 0x61, 0x72, 0x49, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.CarId)
	if err != nil {
		return
	}
	// write "CarName"
	err = en.Append(0xa7, 0x43, 0x61, 0x72, 0x4e, 0x61, 0x6d, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteString(z.CarName)
	if err != nil {
		return
	}
	// write "Attributes"
	err = en.Append(0xaa, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.Attributes)))
	if err != nil {
		return
	}
	for bai := range z.Attributes {
		// map header, size 3
		// write "Id"
		err = en.Append(0x83, 0xa2, 0x49, 0x64)
		if err != nil {
			return err
		}
		err = en.WriteInt(z.Attributes[bai].Id)
		if err != nil {
			return
		}
		// write "Name"
		err = en.Append(0xa4, 0x4e, 0x61, 0x6d, 0x65)
		if err != nil {
			return err
		}
		err = en.WriteString(z.Attributes[bai].Name)
		if err != nil {
			return
		}
		// write "Value"
		err = en.Append(0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65)
		if err != nil {
			return err
		}
		err = en.WriteString(z.Attributes[bai].Value)
		if err != nil {
			return
		}
	}
	// write "FlagMap"
	err = en.Append(0xa7, 0x46, 0x6c, 0x61, 0x67, 0x4d, 0x61, 0x70)
	if err != nil {
		return err
	}
	err = en.WriteMapHeader(uint32(len(z.FlagMap)))
	if err != nil {
		return
	}
	for cmr, ajw := range z.FlagMap {
		err = en.WriteString(cmr)
		if err != nil {
			return
		}
		err = en.WriteString(ajw)
		if err != nil {
			return
		}
	}
	// write "Ttl"
	err = en.Append(0xa3, 0x54, 0x74, 0x6c)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.Ttl)
	if err != nil {
		return
	}
	return
}
開發者ID:darciopacifico,項目名稱:enablecache,代碼行數:90,代碼來源:schema_gen.go


注:本文中的github.com/tinylib/msgp/msgp.Writer.WriteArrayHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。