本文整理匯總了Golang中github.com/youtube/vitess/go/mysql/proto.QueryResult.UnmarshalBson方法的典型用法代碼示例。如果您正苦於以下問題:Golang QueryResult.UnmarshalBson方法的具體用法?Golang QueryResult.UnmarshalBson怎麽用?Golang QueryResult.UnmarshalBson使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/youtube/vitess/go/mysql/proto.QueryResult
的用法示例。
在下文中一共展示了QueryResult.UnmarshalBson方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UnmarshalBson
// UnmarshalBson bson-decodes into QueryResultList.
func (queryResultList *QueryResultList) UnmarshalBson(buf *bytes.Buffer, kind byte) {
switch kind {
case bson.EOO, bson.Object:
// valid
case bson.Null:
return
default:
panic(bson.NewBsonError("unexpected kind %v for QueryResultList", kind))
}
bson.Next(buf, 4)
for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
switch bson.ReadCString(buf) {
case "List":
// []mproto.QueryResult
if kind != bson.Null {
if kind != bson.Array {
panic(bson.NewBsonError("unexpected kind %v for queryResultList.List", kind))
}
bson.Next(buf, 4)
queryResultList.List = make([]mproto.QueryResult, 0, 8)
for kind := bson.NextByte(buf); kind != bson.EOO; kind = bson.NextByte(buf) {
bson.SkipIndex(buf)
var _v1 mproto.QueryResult
_v1.UnmarshalBson(buf, kind)
queryResultList.List = append(queryResultList.List, _v1)
}
}
default:
bson.Skip(buf, kind)
}
}
}
示例2: DecodeResultsBson
func DecodeResultsBson(buf *bytes.Buffer, kind byte) (results []mproto.QueryResult) {
switch kind {
case bson.Array:
// valid
case bson.Null:
return nil
default:
panic(bson.NewBsonError("Unexpected data type %v for Queries", kind))
}
bson.Next(buf, 4)
results = make([]mproto.QueryResult, 0, 8)
kind = bson.NextByte(buf)
var result mproto.QueryResult
for i := 0; kind != bson.EOO; i++ {
bson.ExpectIndex(buf, i)
result.UnmarshalBson(buf)
results = append(results, result)
kind = bson.NextByte(buf)
}
return results
}