本文整理匯總了Golang中github.com/tinylib/msgp/msgp.Writer.WriteUint32方法的典型用法代碼示例。如果您正苦於以下問題:Golang Writer.WriteUint32方法的具體用法?Golang Writer.WriteUint32怎麽用?Golang Writer.WriteUint32使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tinylib/msgp/msgp.Writer
的用法示例。
在下文中一共展示了Writer.WriteUint32方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: EncodeMsg
// EncodeMsg implements msgp.Encodable
func (z Outgoing) EncodeMsg(en *msgp.Writer) (err error) {
// map header, size 3
// write "time"
err = en.Append(0x83, 0xa4, 0x74, 0x69, 0x6d, 0x65)
if err != nil {
return err
}
err = en.WriteUint32(z.Time)
if err != nil {
return
}
// write "from"
err = en.Append(0xa4, 0x66, 0x72, 0x6f, 0x6d)
if err != nil {
return err
}
err = en.WriteString(z.From)
if err != nil {
return
}
// write "message"
err = en.Append(0xa7, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65)
if err != nil {
return err
}
err = en.WriteString(z.Message)
if err != nil {
return
}
return
}
示例2: 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
}
示例3: 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()
}