当前位置: 首页>>代码示例>>Golang>>正文


Golang Writer.WriteNil方法代码示例

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


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

示例1: 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

示例2: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z *bitmapContainerShortIterator) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 2
	// write "ptr"
	err = en.Append(0x82, 0xa3, 0x70, 0x74, 0x72)
	if err != nil {
		return err
	}
	if z.ptr == nil {
		err = en.WriteNil()
		if err != nil {
			return
		}
	} else {
		// 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.ptr.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.ptr.bitmap)))
		if err != nil {
			return
		}
		for zwht := range z.ptr.bitmap {
			err = en.WriteUint64(z.ptr.bitmap[zwht])
			if err != nil {
				return
			}
		}
	}
	// write "i"
	err = en.Append(0xa1, 0x69)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.i)
	if err != nil {
		return
	}
	return
}
开发者ID:RoaringBitmap,项目名称:roaring,代码行数:51,代码来源:bitmapcontainer_gen.go

示例3: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z *runIterator32) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 4
	// write "rc"
	err = en.Append(0x84, 0xa2, 0x72, 0x63)
	if err != nil {
		return err
	}
	if z.rc == nil {
		err = en.WriteNil()
		if err != nil {
			return
		}
	} else {
		err = z.rc.EncodeMsg(en)
		if err != nil {
			return
		}
	}
	// write "curIndex"
	err = en.Append(0xa8, 0x63, 0x75, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78)
	if err != nil {
		return err
	}
	err = en.WriteInt64(z.curIndex)
	if err != nil {
		return
	}
	// write "curPosInIndex"
	err = en.Append(0xad, 0x63, 0x75, 0x72, 0x50, 0x6f, 0x73, 0x49, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78)
	if err != nil {
		return err
	}
	err = en.WriteUint32(z.curPosInIndex)
	if err != nil {
		return
	}
	// write "curSeq"
	err = en.Append(0xa6, 0x63, 0x75, 0x72, 0x53, 0x65, 0x71)
	if err != nil {
		return err
	}
	err = en.WriteInt64(z.curSeq)
	if err != nil {
		return
	}
	return
}
开发者ID:RoaringBitmap,项目名称:roaring,代码行数:48,代码来源:rle_gen.go

示例4: 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

示例5: 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

示例6: EncodeMsg

// EncodeMsg implements msgp.Encodable
func (z *Message) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 5
	// write "id"
	err = en.Append(0x85, 0xa2, 0x69, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteUint64(z.ID)
	if err != nil {
		return
	}
	// write "fn"
	err = en.Append(0xa2, 0x66, 0x6e)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Func)
	if err != nil {
		return
	}
	// write "args"
	err = en.Append(0xa4, 0x61, 0x72, 0x67, 0x73)
	if err != nil {
		return err
	}
	err = z.Args.EncodeMsg(en)
	if err != nil {
		return
	}
	// write "result"
	err = en.Append(0xa6, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74)
	if err != nil {
		return err
	}
	err = z.Result.EncodeMsg(en)
	if err != nil {
		return
	}
	// write "error"
	err = en.Append(0xa5, 0x65, 0x72, 0x72, 0x6f, 0x72)
	if err != nil {
		return err
	}
	if z.Error == nil {
		err = en.WriteNil()
		if err != nil {
			return
		}
	} else {
		// map header, size 1
		// write "msg"
		err = en.Append(0x81, 0xa3, 0x6d, 0x73, 0x67)
		if err != nil {
			return err
		}
		err = en.WriteString(z.Error.Msg)
		if err != nil {
			return
		}
	}
	return
}
开发者ID:sztanpet,项目名称:bimpc,代码行数:63,代码来源:mpc_gen.go


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