當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Reader.ReadString方法代碼示例

本文整理匯總了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
}
開發者ID:CadeLaRen,項目名稱:docker-3,代碼行數:29,代碼來源:proto_gen.go

示例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
}
開發者ID:sztanpet,項目名稱:bimpc,代碼行數:30,代碼來源:mpc_gen.go

示例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
}
開發者ID:micro,項目名稱:go-plugins,代碼行數:59,代碼來源:rpc.go

示例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
}
開發者ID:darciopacifico,項目名稱:enablecache,代碼行數:55,代碼來源:manager_gen.go

示例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
}
開發者ID:glycerine,項目名稱:zebra,代碼行數:55,代碼來源:zebra_gen.go

示例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
}
開發者ID:andyleap,項目名稱:gencode,代碼行數:55,代碼來源:test.schema.gen_gen.go

示例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
}
開發者ID:ZloyDyadka,項目名稱:socketcrutch,代碼行數:45,代碼來源:packet_gen.go

示例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
}
開發者ID:glycerine,項目名稱:zygomys,代碼行數:45,代碼來源:demo_go_structs_gen.go

示例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
}
開發者ID:darciopacifico,項目名稱:enablecache,代碼行數:40,代碼來源:schema_gen.go

示例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
}
開發者ID:mengzhuo,項目名稱:zerorpc-golang,代碼行數:40,代碼來源:protocal_gen.go

示例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
}
開發者ID:sztanpet,項目名稱:bimpc,代碼行數:40,代碼來源:main_gen.go

示例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
}
開發者ID:noxiouz,項目名稱:stout,代碼行數:23,代碼來源:initialdispatch.go

示例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)
    }
}
開發者ID:noxiouz,項目名稱:stout,代碼行數:54,代碼來源:initialdispatch.go

示例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
}
開發者ID:jmptrader,項目名稱:pluq,代碼行數:62,代碼來源:message_gen.go

示例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
}
開發者ID:aglagla,項目名稱:raintank-metric,代碼行數:82,代碼來源:metric_gen.go


注:本文中的github.com/tinylib/msgp/msgp.Reader.ReadString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。