本文整理汇总了Golang中github.com/funny-falcon/go-iproto/marshal.Writer.Uint32方法的典型用法代码示例。如果您正苦于以下问题:Golang Writer.Uint32方法的具体用法?Golang Writer.Uint32怎么用?Golang Writer.Uint32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/funny-falcon/go-iproto/marshal.Writer
的用法示例。
在下文中一共展示了Writer.Uint32方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: IWrite
func (o Op) IWrite(w *marshal.Writer) {
w.Write(o.Field)
if o.Op <= 7 {
w.Write(o.Op)
} else {
w.Write(opmap[o.Op])
}
switch v := o.Val.(type) {
case uint32:
w.Int8(4)
w.Uint32(v)
case uint64:
w.Int8(8)
w.Uint64(v)
case int32:
w.Int8(4)
w.Int32(v)
case int64:
w.Int8(8)
w.Int64(v)
case []byte:
w.Intvar(len(v))
w.Bytes(v)
case string:
w.Intvar(len(v))
w.String(v)
default:
val := reflect.ValueOf(v)
wr := marshal.WriterFor(val.Type())
wr.WithSize(w, val, (*marshal.Writer).Intvar)
}
}
示例2: IWrite
func (s SelectReq) IWrite(w *marshal.Writer) {
w.Uint32(s.Space)
w.Uint32(s.Index)
w.Uint32(s.Offset)
cnt := CountKeys(s.Keys)
if s.Limit >= 0 {
w.Int32(s.Limit)
} else if s.Limit == SelectN {
w.Int32(int32(cnt))
} else {
w.Int32(1<<31 - 1)
}
w.IntUint32(cnt)
WriteKeys(w, s.Keys)
}
示例3: WriteTuple
func WriteTuple(w *marshal.Writer, i interface{}) {
switch o := i.(type) {
case nil:
return
case uint8:
w.Uint32(1)
w.Uint8(1)
w.Uint8(o)
case int8:
w.Uint32(1)
w.Uint8(1)
w.Int8(o)
case uint16:
w.Uint32(1)
w.Uint8(2)
w.Uint16(o)
case int16:
w.Uint32(1)
w.Uint8(2)
w.Int16(o)
case uint32:
w.Uint32(1)
w.Uint8(4)
w.Uint32(o)
case int32:
w.Uint32(1)
w.Uint8(4)
w.Int32(o)
case uint64:
w.Uint32(1)
w.Uint8(8)
w.Uint64(o)
case int64:
w.Uint32(1)
w.Uint8(8)
w.Int64(o)
case float32:
w.Uint32(1)
w.Uint8(4)
w.Float32(o)
case float64:
w.Uint32(1)
w.Uint8(8)
w.Float64(o)
case string:
w.Uint32(1)
w.Intvar(len(o))
w.String(o)
case []byte:
w.Uint32(1)
w.Intvar(len(o))
w.Bytes(o)
case []interface{}:
w.IntUint32(len(o))
for _, v := range o {
w.WriteWithSize(v, (*marshal.Writer).Intvar)
}
default:
val := reflect.ValueOf(i)
rt := val.Type()
wr := writer(rt)
wr.Write(w, val)
}
return
}