本文整理匯總了Golang中github.com/funny-falcon/go-iproto/marshal.Reader.Err方法的典型用法代碼示例。如果您正苦於以下問題:Golang Reader.Err方法的具體用法?Golang Reader.Err怎麽用?Golang Reader.Err使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/funny-falcon/go-iproto/marshal.Reader
的用法示例。
在下文中一共展示了Reader.Err方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: oneFieldTuple
func oneFieldTuple(r *marshal.Reader, sz int) bool {
var l, s int
if l = r.IntUint32(); l >= 1 {
if s = r.Intvar(); s == sz {
return true
} else {
r.Err = fmt.Errorf("Wrong field size: expect 1, got %d", l)
}
} else {
r.Err = fmt.Errorf("Wrong field count: expect 1, got %d", l)
}
return false
}
示例2: ReadSizedTuple
func ReadSizedTuple(r *marshal.Reader, i interface{}) error {
sz := r.IntUint32()
if r.Err == nil {
rd := marshal.Reader{Body: r.Slice(sz + 4)}
r.Err = ReadRawTuple(&rd, i)
}
return r.Err
}
示例3: string
func (t *TReader) string(r *marshal.Reader, v reflect.Value) {
if l := r.Uint32(); l >= 1 {
sz := r.Intvar()
v.SetString(r.String(sz))
} else {
r.Err = fmt.Errorf("Wrong field count: expect 1, got %d", l)
}
}
示例4: sliceFixed
func (t *TReader) sliceFixed(r *marshal.Reader, v reflect.Value) {
if l := r.IntUint32(); l >= v.Len() {
for i := 0; i < l; i++ {
t.Reader.Elem.WithSize(r, v.Index(i), (*marshal.Reader).Intvar)
}
} else {
r.Err = fmt.Errorf("Wrong field count: expect %d, got %d", v.Len(), l)
}
}
示例5: bytesAuto
func (t *TReader) bytesAuto(r *marshal.Reader, v reflect.Value) {
if !v.CanSet() {
t.bytesFixed(r, v)
return
}
if l := r.IntUint32(); l >= 1 {
t.Reader.WithSize(r, v, (*marshal.Reader).Intvar)
} else {
r.Err = fmt.Errorf("Wrong field count: expect 1, got %d", l)
}
}
示例6: sliceAuto
func (t *TReader) sliceAuto(r *marshal.Reader, v reflect.Value) {
l := r.IntUint32()
if v.CanSet() {
v.Set(reflect.MakeSlice(v.Type(), l, l))
} else if l < v.Len() {
r.Err = fmt.Errorf("Wrong field count: expect %d, got %d", v.Len(), l)
return
}
for i := 0; i < l; i++ {
t.Reader.Elem.WithSize(r, v.Index(i), (*marshal.Reader).Intvar)
}
}