本文整理汇总了Golang中github.com/tinylib/msgp/msgp.Reader.ReadString方法的典型用法代码示例。如果您正苦于以下问题:Golang Reader.ReadString方法的具体用法?Golang Reader.ReadString怎么用?Golang Reader.ReadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tinylib/msgp/msgp.Reader
的用法示例。
在下文中一共展示了Reader.ReadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DecodeMsg
// DecodeMsg implements msgp.Decodable
func (z *Message) DecodeMsg(dc *msgp.Reader) (err error) {
var ssz uint32
ssz, err = dc.ReadArrayHeader()
if err != nil {
return
}
if ssz != 4 {
err = msgp.ArrayError{Wanted: 4, Got: ssz}
return
}
z.Tag, err = dc.ReadString()
if err != nil {
return
}
z.Time, err = dc.ReadInt64()
if err != nil {
return
}
z.Record, err = dc.ReadIntf()
if err != nil {
return
}
z.Option, err = dc.ReadIntf()
if err != nil {
return
}
return
}
示例2: DecodeMsg
// DecodeMsg implements msgp.Decodable
func (z *Error) DecodeMsg(dc *msgp.Reader) (err error) {
var field []byte
_ = field
var isz uint32
isz, err = dc.ReadMapHeader()
if err != nil {
return
}
for isz > 0 {
isz--
field, err = dc.ReadMapKeyPtr()
if err != nil {
return
}
switch msgp.UnsafeString(field) {
case "msg":
z.Msg, err = dc.ReadString()
if err != nil {
return
}
default:
err = dc.Skip()
if err != nil {
return
}
}
}
return
}
示例3: DecodeMsg
func (r *Request) DecodeMsg(mr *msgp.Reader) error {
var bm msgp.Decodable
if r.Body != nil {
var ok bool
bm, ok = r.Body.(msgp.Decodable)
if !ok {
return ErrNotDecodable
}
}
if size, err := mr.ReadArrayHeader(); err != nil {
return err
} else if size != RequestPackSize {
return ErrBadPackSize
}
if typ, err := mr.ReadInt(); err != nil {
return err
} else if typ != RequestType {
return ErrBadMessageType
}
id, err := mr.ReadUint32()
if err != nil {
return err
}
r.ID = id
method, err := mr.ReadString()
if err != nil {
return err
}
r.Method = method
// The request body is packed in an array.
l, err := mr.ReadArrayHeader()
if err != nil {
return err
}
if l > 1 {
return ErrUnexpectedParams
} else if l == 0 {
return nil
}
r.hasBody = true
// Skip decoding the body if no value is present to decode into.
// The caller is expected to decode the body or skip it.
if bm != nil {
return decodeBody(mr, bm)
}
return nil
}
示例4: DecodeMsg
// DecodeMsg implements msgp.Decodable
func (z *CacheRegistry) DecodeMsg(dc *msgp.Reader) (err error) {
var field []byte
_ = field
var xvk uint32
xvk, err = dc.ReadMapHeader()
if err != nil {
return
}
for xvk > 0 {
xvk--
field, err = dc.ReadMapKeyPtr()
if err != nil {
return
}
switch msgp.UnsafeString(field) {
case "CacheKey":
z.CacheKey, err = dc.ReadString()
if err != nil {
return
}
case "Payload":
z.Payload, err = dc.ReadIntf()
if err != nil {
return
}
case "StoreTTL":
z.StoreTTL, err = dc.ReadFloat64()
if err != nil {
return
}
case "CacheTime":
z.CacheTime, err = dc.ReadTime()
if err != nil {
return
}
case "HasValue":
z.HasValue, err = dc.ReadBool()
if err != nil {
return
}
case "TypeName":
z.TypeName, err = dc.ReadString()
if err != nil {
return
}
default:
err = dc.Skip()
if err != nil {
return
}
}
}
return
}
示例5: DecodeMsg
// DecodeMsg implements msgp.Decodable
func (z *MethodT) DecodeMsg(dc *msgp.Reader) (err error) {
var field []byte
_ = field
var zcxo uint32
zcxo, err = dc.ReadMapHeader()
if err != nil {
return
}
for zcxo > 0 {
zcxo--
field, err = dc.ReadMapKeyPtr()
if err != nil {
return
}
switch msgp.UnsafeString(field) {
case "MethodId":
z.MethodId, err = dc.ReadInt64()
if err != nil {
return
}
case "Name":
z.Name, err = dc.ReadString()
if err != nil {
return
}
case "Inputs":
err = z.Inputs.DecodeMsg(dc)
if err != nil {
return
}
case "Returns":
err = z.Returns.DecodeMsg(dc)
if err != nil {
return
}
case "Deprecated":
z.Deprecated, err = dc.ReadBool()
if err != nil {
return
}
case "Comment":
z.Comment, err = dc.ReadString()
if err != nil {
return
}
default:
err = dc.Skip()
if err != nil {
return
}
}
}
return
}
示例6: DecodeMsg
// DecodeMsg implements msgp.Decodable
func (z *A) DecodeMsg(dc *msgp.Reader) (err error) {
var field []byte
_ = field
var isz uint32
isz, err = dc.ReadMapHeader()
if err != nil {
return
}
for isz > 0 {
isz--
field, err = dc.ReadMapKeyPtr()
if err != nil {
return
}
switch msgp.UnsafeString(field) {
case "Name":
z.Name, err = dc.ReadString()
if err != nil {
return
}
case "BirthDay":
z.BirthDay, err = dc.ReadInt64()
if err != nil {
return
}
case "Phone":
z.Phone, err = dc.ReadString()
if err != nil {
return
}
case "Siblings":
z.Siblings, err = dc.ReadInt64()
if err != nil {
return
}
case "Spouse":
z.Spouse, err = dc.ReadUint8()
if err != nil {
return
}
case "Money":
z.Money, err = dc.ReadFloat64()
if err != nil {
return
}
default:
err = dc.Skip()
if err != nil {
return
}
}
}
return
}
示例7: DecodeMsg
// DecodeMsg implements msgp.Decodable
func (z *Packet) DecodeMsg(dc *msgp.Reader) (err error) {
var field []byte
_ = field
var isz uint32
isz, err = dc.ReadMapHeader()
if err != nil {
return
}
for isz > 0 {
isz--
field, err = dc.ReadMapKeyPtr()
if err != nil {
return
}
switch msgp.UnsafeString(field) {
case "type":
z.pType, err = dc.ReadByte()
if err != nil {
return
}
case "id":
z.id, err = dc.ReadInt()
if err != nil {
return
}
case "event":
z.eventName, err = dc.ReadString()
if err != nil {
return
}
case "payload":
z.payload, err = dc.ReadBytes(z.payload)
if err != nil {
return
}
default:
err = dc.Skip()
if err != nil {
return
}
}
}
return
}
示例8: DecodeMsg
// DecodeMsg implements msgp.Decodable
func (z *Weather) DecodeMsg(dc *msgp.Reader) (err error) {
var field []byte
_ = field
var isz uint32
isz, err = dc.ReadMapHeader()
if err != nil {
return
}
for isz > 0 {
isz--
field, err = dc.ReadMapKeyPtr()
if err != nil {
return
}
switch msgp.UnsafeString(field) {
case "time":
z.Time, err = dc.ReadTime()
if err != nil {
return
}
case "size":
z.Size, err = dc.ReadInt64()
if err != nil {
return
}
case "type":
z.Type, err = dc.ReadString()
if err != nil {
return
}
case "details":
z.Details, err = dc.ReadBytes(z.Details)
if err != nil {
return
}
default:
err = dc.Skip()
if err != nil {
return
}
}
}
return
}
示例9: DecodeMsg
// DecodeMsg implements msgp.Decodable
func (z *Attribute) DecodeMsg(dc *msgp.Reader) (err error) {
var field []byte
_ = field
var xvk uint32
xvk, err = dc.ReadMapHeader()
if err != nil {
return
}
for xvk > 0 {
xvk--
field, err = dc.ReadMapKeyPtr()
if err != nil {
return
}
switch msgp.UnsafeString(field) {
case "Id":
z.Id, err = dc.ReadInt()
if err != nil {
return
}
case "Name":
z.Name, err = dc.ReadString()
if err != nil {
return
}
case "Value":
z.Value, err = dc.ReadString()
if err != nil {
return
}
default:
err = dc.Skip()
if err != nil {
return
}
}
}
return
}
示例10: DecodeMsg
// DecodeMsg implements msgp.Decodable
func (z *EventHeader) DecodeMsg(dc *msgp.Reader) (err error) {
var field []byte
_ = field
var isz uint32
isz, err = dc.ReadMapHeader()
if err != nil {
return
}
for isz > 0 {
isz--
field, err = dc.ReadMapKeyPtr()
if err != nil {
return
}
switch msgp.UnsafeString(field) {
case "message_id":
z.Id, err = dc.ReadString()
if err != nil {
return
}
case "v":
z.Version, err = dc.ReadInt()
if err != nil {
return
}
case "response_to":
z.ResponseTo, err = dc.ReadString()
if err != nil {
return
}
default:
err = dc.Skip()
if err != nil {
return
}
}
}
return
}
示例11: DecodeMsg
// DecodeMsg implements msgp.Decodable
func (z *Outgoing) DecodeMsg(dc *msgp.Reader) (err error) {
var field []byte
_ = field
var isz uint32
isz, err = dc.ReadMapHeader()
if err != nil {
return
}
for isz > 0 {
isz--
field, err = dc.ReadMapKeyPtr()
if err != nil {
return
}
switch msgp.UnsafeString(field) {
case "time":
z.Time, err = dc.ReadUint32()
if err != nil {
return
}
case "from":
z.From, err = dc.ReadString()
if err != nil {
return
}
case "message":
z.Message, err = dc.ReadString()
if err != nil {
return
}
default:
err = dc.Skip()
if err != nil {
return
}
}
}
return
}
示例12: readMapStrStr
func readMapStrStr(r *msgp.Reader, mp map[string]string) (err error) {
var sz uint32
sz, err = r.ReadMapHeader()
if err != nil {
return err
}
for i := uint32(0); i < sz; i++ {
var key string
var val string
key, err = r.ReadString()
if err != nil {
return err
}
val, err = r.ReadString()
if err != nil {
return err
}
mp[key] = val
}
return
}
示例13: Handle
func (d *initialDispatch) Handle(id uint64, r *msgp.Reader) (Dispatcher, error) {
var err error
switch id {
case spool:
var opts = make(Profile)
var name string
if err = checkSize(_onSpoolArgsNum, r); err != nil {
return nil, err
}
if err = r.ReadMapStrIntf(opts); err != nil {
return nil, err
}
if name, err = r.ReadString(); err != nil {
return nil, err
}
return d.onSpool(opts, name)
case spawn:
var (
opts = make(Profile)
name, executable string
args = make(map[string]string)
env = make(map[string]string)
)
if err = checkSize(_onSpawnArgsNum, r); err != nil {
return nil, err
}
if err = r.ReadMapStrIntf(opts); err != nil {
return nil, err
}
if name, err = r.ReadString(); err != nil {
return nil, err
}
if executable, err = r.ReadString(); err != nil {
return nil, err
}
if err = readMapStrStr(r, args); err != nil {
return nil, err
}
if err = readMapStrStr(r, env); err != nil {
return nil, err
}
return d.onSpawn(opts, name, executable, args, env)
default:
return nil, fmt.Errorf("unknown transition id: %d", id)
}
}
示例14: DecodeMsg
// DecodeMsg implements msgp.Decodable
func (z *Message) DecodeMsg(dc *msgp.Reader) (err error) {
var field []byte
_ = field
var isz uint32
isz, err = dc.ReadMapHeader()
if err != nil {
return
}
for isz > 0 {
isz--
field, err = dc.ReadMapKeyPtr()
if err != nil {
return
}
switch msgp.UnsafeString(field) {
case "body":
z.Body, err = dc.ReadBytes(z.Body)
if err != nil {
return
}
case "meta":
var msz uint32
msz, err = dc.ReadMapHeader()
if err != nil {
return
}
if z.Meta == nil && msz > 0 {
z.Meta = make(map[string]interface{}, msz)
} else if len(z.Meta) > 0 {
for key, _ := range z.Meta {
delete(z.Meta, key)
}
}
for msz > 0 {
msz--
var xvk string
var bzg interface{}
xvk, err = dc.ReadString()
if err != nil {
return
}
bzg, err = dc.ReadIntf()
if err != nil {
return
}
z.Meta[xvk] = bzg
}
case "ct":
z.ContentType, err = dc.ReadString()
if err != nil {
return
}
default:
err = dc.Skip()
if err != nil {
return
}
}
}
return
}
示例15: DecodeMsg
// DecodeMsg implements msgp.Decodable
func (z *MetricData) DecodeMsg(dc *msgp.Reader) (err error) {
var field []byte
_ = field
var isz uint32
isz, err = dc.ReadMapHeader()
if err != nil {
return
}
for isz > 0 {
isz--
field, err = dc.ReadMapKeyPtr()
if err != nil {
return
}
switch msgp.UnsafeString(field) {
case "OrgId":
z.OrgId, err = dc.ReadInt()
if err != nil {
return
}
case "Name":
z.Name, err = dc.ReadString()
if err != nil {
return
}
case "Metric":
z.Metric, err = dc.ReadString()
if err != nil {
return
}
case "Interval":
z.Interval, err = dc.ReadInt()
if err != nil {
return
}
case "Value":
z.Value, err = dc.ReadFloat64()
if err != nil {
return
}
case "Unit":
z.Unit, err = dc.ReadString()
if err != nil {
return
}
case "Time":
z.Time, err = dc.ReadInt64()
if err != nil {
return
}
case "TargetType":
z.TargetType, err = dc.ReadString()
if err != nil {
return
}
case "Tags":
var xsz uint32
xsz, err = dc.ReadArrayHeader()
if err != nil {
return
}
if cap(z.Tags) >= int(xsz) {
z.Tags = z.Tags[:xsz]
} else {
z.Tags = make([]string, xsz)
}
for xvk := range z.Tags {
z.Tags[xvk], err = dc.ReadString()
if err != nil {
return
}
}
default:
err = dc.Skip()
if err != nil {
return
}
}
}
return
}