本文整理匯總了Golang中code/google/com/p/goprotobuf/proto.Bool函數的典型用法代碼示例。如果您正苦於以下問題:Golang Bool函數的具體用法?Golang Bool怎麽用?Golang Bool使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Bool函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newPresenceResponse
func newPresenceResponse(isAvailable bool, presence pb.PresenceResponse_SHOW, valid bool) *pb.PresenceResponse {
return &pb.PresenceResponse{
IsAvailable: proto.Bool(isAvailable),
Presence: presence.Enum(),
Valid: proto.Bool(valid),
}
}
示例2: TestParseSectionDnsTableA_Valid
func TestParseSectionDnsTableA_Valid(t *testing.T) {
lines := []string{
"10 11",
"12 13 0 DOM1 IP1 14",
"15 16 1 DOM2 IP2 17",
}
trace := Trace{}
err := parseSectionDnsTableA(lines, &trace)
if err != nil {
t.Fatal("Unexpected error:", err)
}
expectedTrace := Trace{
ARecordsDropped: proto.Int32(10),
CnameRecordsDropped: proto.Int32(11),
ARecord: []*DnsARecord{
&DnsARecord{
PacketId: proto.Int32(12),
AddressId: proto.Int32(13),
Anonymized: proto.Bool(false),
Domain: proto.String("DOM1"),
IpAddress: proto.String("IP1"),
Ttl: proto.Int32(14),
},
&DnsARecord{
PacketId: proto.Int32(15),
AddressId: proto.Int32(16),
Anonymized: proto.Bool(true),
Domain: proto.String("DOM2"),
IpAddress: proto.String("IP2"),
Ttl: proto.Int32(17),
},
},
}
checkProtosEqual(t, &expectedTrace, &trace)
}
示例3: toProto
// toProto converts the query to a protocol buffer.
func (q *Query) toProto(dst *pb.Query, appID string) error {
if q.kind == "" {
return errors.New("datastore: empty query kind")
}
dst.Reset()
dst.App = proto.String(appID)
dst.Kind = proto.String(q.kind)
if q.ancestor != nil {
dst.Ancestor = keyToProto(appID, q.ancestor)
}
if q.keysOnly {
dst.KeysOnly = proto.Bool(true)
dst.RequirePerfectPlan = proto.Bool(true)
}
for _, qf := range q.filter {
if qf.FieldName == "" {
return errors.New("datastore: empty query filter field name")
}
p, errStr := valueToProto(appID, qf.FieldName, reflect.ValueOf(qf.Value), false)
if errStr != "" {
return errors.New("datastore: bad query filter value type: " + errStr)
}
xf := &pb.Query_Filter{
Op: operatorToProto[qf.Op],
Property: []*pb.Property{p},
}
if xf.Op == nil {
return errors.New("datastore: unknown query filter operator")
}
dst.Filter = append(dst.Filter, xf)
}
for _, qo := range q.order {
if qo.FieldName == "" {
return errors.New("datastore: empty query order field name")
}
xo := &pb.Query_Order{
Property: proto.String(qo.FieldName),
Direction: sortDirectionToProto[qo.Direction],
}
if xo.Direction == nil {
return errors.New("datastore: unknown query order direction")
}
dst.Order = append(dst.Order, xo)
}
if q.limit >= 0 {
dst.Limit = proto.Int32(q.limit)
}
if q.offset != 0 {
dst.Offset = proto.Int32(q.offset)
}
dst.CompiledCursor = q.start
dst.EndCompiledCursor = q.end
dst.Compile = proto.Bool(true)
return nil
}
示例4: fakeRunQuery
func fakeRunQuery(in *pb.Query, out *pb.QueryResult) error {
expectedIn := &pb.Query{
App: proto.String("dev~fake-app"),
Kind: proto.String("Gopher"),
Compile: proto.Bool(true),
}
if !proto.Equal(in, expectedIn) {
return fmt.Errorf("unsupported argument: got %v want %v", in, expectedIn)
}
*out = pb.QueryResult{
Result: []*pb.EntityProto{
{
Key: &pb.Reference{
App: proto.String("s~test-app"),
Path: path1,
},
EntityGroup: path1,
Property: []*pb.Property{
{
Meaning: pb.Property_TEXT.Enum(),
Name: proto.String("Name"),
Value: &pb.PropertyValue{
StringValue: proto.String("George"),
},
},
{
Name: proto.String("Height"),
Value: &pb.PropertyValue{
Int64Value: proto.Int64(32),
},
},
},
},
{
Key: &pb.Reference{
App: proto.String("s~test-app"),
Path: path2,
},
EntityGroup: path1, // ancestor is George
Property: []*pb.Property{
{
Meaning: pb.Property_TEXT.Enum(),
Name: proto.String("Name"),
Value: &pb.PropertyValue{
StringValue: proto.String("Rufus"),
},
},
// No height for Rufus.
},
},
},
MoreResults: proto.Bool(false),
}
return nil
}
示例5: FreezeGroup
// Freeze a Group into a flattened protobuf-based structure
// ready to be persisted to disk.
func FreezeGroup(group acl.Group) (*freezer.Group, error) {
frozenGroup := &freezer.Group{}
frozenGroup.Name = proto.String(group.Name)
frozenGroup.Inherit = proto.Bool(group.Inherit)
frozenGroup.Inheritable = proto.Bool(group.Inheritable)
for _, id := range group.AddUsers() {
frozenGroup.Add = append(frozenGroup.Add, uint32(id))
}
for _, id := range group.RemoveUsers() {
frozenGroup.Remove = append(frozenGroup.Remove, uint32(id))
}
return frozenGroup, nil
}
示例6: FreezeACL
// Freeze a ChannelACL into it a flattened protobuf-based structure
// ready to be persisted to disk.
func FreezeACL(aclEntry acl.ACL) (*freezer.ACL, error) {
frozenAcl := &freezer.ACL{}
if aclEntry.UserId != -1 {
frozenAcl.UserId = proto.Uint32(uint32(aclEntry.UserId))
} else {
frozenAcl.Group = proto.String(aclEntry.Group)
}
frozenAcl.ApplyHere = proto.Bool(aclEntry.ApplyHere)
frozenAcl.ApplySubs = proto.Bool(aclEntry.ApplySubs)
frozenAcl.Allow = proto.Uint32(uint32(aclEntry.Allow))
frozenAcl.Deny = proto.Uint32(uint32(aclEntry.Deny))
return frozenAcl, nil
}
示例7: handleHello
func (p *Peer) handleHello(m *Manager, hello *protocol.Hello) {
cookie, err := p.getSessionCookie()
if err != nil {
glog.Errorf("%s:Bad cookie: %s", p.String(), err.Error())
p.UpdateStatus(HelloFailed)
return
}
pubKey, err := crypto.ParsePublicKeyFromHash(hello.GetNodePublic())
if err != nil {
glog.Errorf("Bad public key: %X", hello.GetNodePublic())
p.UpdateStatus(HelloFailed)
return
}
ok, err := crypto.Verify(pubKey.SerializeUncompressed(), hello.GetNodeProof(), cookie)
if !ok {
glog.Errorf("%s:Bad signature: %X public key: %X hash: %X", p.String(), hello.GetNodeProof(), hello.GetNodePublic(), cookie)
p.UpdateStatus(HelloFailed)
return
}
if err != nil {
glog.Errorf("%s:Bad signature verification: %s", p.String(), err.Error())
p.UpdateStatus(HelloFailed)
return
}
proof, err := m.Key.Sign(cookie)
if err != nil {
glog.Errorf("%s:Bad signature creation: %X", p.String(), cookie)
p.UpdateStatus(HelloFailed)
return
}
if err := p.ProcessHello(hello); err != nil {
glog.Errorf("%s:%s", p.String(), err.Error())
return
}
port, _ := strconv.ParseUint(m.Port, 10, 32)
p.Outgoing <- &protocol.TMHello{
FullVersion: proto.String(m.Name),
ProtoVersion: proto.Uint32(uint32(maxVersion)),
ProtoVersionMin: proto.Uint32(uint32(minVersion)),
NodePublic: []byte(m.PublicKey.String()),
NodeProof: proof,
Ipv4Port: proto.Uint32(uint32(port)),
NetTime: proto.Uint64(uint64(data.Now().Uint32())),
NodePrivate: proto.Bool(true),
TestNet: proto.Bool(false),
}
if hello.ProofOfWork != nil {
go p.handleProofOfWork(hello.ProofOfWork)
}
}
示例8: parseSuccessCode
func parseSuccessCode(succ uint32) *contester_proto.ExecutionResultFlags {
if succ == 0 {
return nil
}
result := &contester_proto.ExecutionResultFlags{}
if succ&subprocess.EF_KILLED != 0 {
result.Killed = proto.Bool(true)
}
if succ&subprocess.EF_TIME_LIMIT_HIT != 0 {
result.TimeLimitHit = proto.Bool(true)
}
if succ&subprocess.EF_MEMORY_LIMIT_HIT != 0 {
result.MemoryLimitHit = proto.Bool(true)
}
if succ&subprocess.EF_INACTIVE != 0 {
result.Inactive = proto.Bool(true)
}
if succ&subprocess.EF_TIME_LIMIT_HARD != 0 {
result.TimeLimitHard = proto.Bool(true)
}
if succ&subprocess.EF_TIME_LIMIT_HIT_POST != 0 {
result.TimeLimitHitPost = proto.Bool(true)
}
if succ&subprocess.EF_MEMORY_LIMIT_HIT_POST != 0 {
result.MemoryLimitHitPost = proto.Bool(true)
}
if succ&subprocess.EF_PROCESS_LIMIT_HIT != 0 {
result.ProcessLimitHit = proto.Bool(true)
}
return result
}
示例9: duplicateProtoList
func duplicateProtoList(duplicates []*models.DuplicateData, configs []*models.ConfigDuplicate) []*protodata.ChapterData {
//list := models.ConfigDuplicateList()
var result []*protodata.ChapterData
result = append(result, &protodata.ChapterData{
ChapterId: proto.Int32(int32(configs[0].Chapter)),
ChapterName: proto.String(configs[0].ChapterName),
ChapterDesc: proto.String(""),
IsUnlock: proto.Bool(true),
})
for index, section := range configs {
var sectionProto protodata.SectionData
sectionProto.SectionId = proto.Int32(int32(section.Section))
sectionProto.SectionName = proto.String(section.SectionName)
sectionProto.SectionDesc = proto.String("")
sectionProto.IsUnlock = proto.Bool(true)
var find bool
if index > 0 {
for _, d := range duplicates {
if d.Chapter == configs[index-1].Chapter && d.Section == configs[index-1].Section {
find = true
break
} else {
find = false
}
}
if !find {
sectionProto.IsUnlock = proto.Bool(false)
}
}
if section.Chapter != int(*result[len(result)-1].ChapterId) {
result = append(result, &protodata.ChapterData{
ChapterId: proto.Int32(int32(section.Chapter)),
ChapterName: proto.String(section.ChapterName),
ChapterDesc: proto.String(""),
IsUnlock: proto.Bool(find),
})
}
result[len(result)-1].Sections = append(result[len(result)-1].Sections, §ionProto)
}
return result
}
示例10: Freeze
// Freeze a ChannelACL into it a flattened protobuf-based structure
// ready to be persisted to disk.
func (acl *ChannelACL) Freeze() (facl *freezer.ACL, err error) {
facl = new(freezer.ACL)
if acl.UserId != -1 {
facl.UserId = proto.Uint32(uint32(acl.UserId))
} else {
facl.Group = proto.String(acl.Group)
}
facl.ApplyHere = proto.Bool(acl.ApplyHere)
facl.ApplySubs = proto.Bool(acl.ApplySubs)
facl.Allow = proto.Uint32(uint32(acl.Allow))
facl.Deny = proto.Uint32(uint32(acl.Deny))
return
}
示例11: lease
func lease(c appengine.Context, maxTasks int, queueName string, leaseTime int, groupByTag bool, tag []byte) ([]*Task, error) {
req := &taskqueue_proto.TaskQueueQueryAndOwnTasksRequest{
QueueName: []byte(queueName),
LeaseSeconds: proto.Float64(float64(leaseTime)),
MaxTasks: proto.Int64(int64(maxTasks)),
GroupByTag: proto.Bool(groupByTag),
Tag: tag,
}
res := &taskqueue_proto.TaskQueueQueryAndOwnTasksResponse{}
callOpts := &appengine_internal.CallOptions{
Timeout: 10 * time.Second,
}
if err := c.Call("taskqueue", "QueryAndOwnTasks", req, res, callOpts); err != nil {
return nil, err
}
tasks := make([]*Task, len(res.Task))
for i, t := range res.Task {
tasks[i] = &Task{
Payload: t.Body,
Name: string(t.TaskName),
Method: "PULL",
ETA: time.Unix(0, *t.EtaUsec*1e3),
RetryCount: *t.RetryCount,
Tag: string(t.Tag),
}
}
return tasks, nil
}
示例12: ExampleLookupsPerDevice_oneDomain
func ExampleLookupsPerDevice_oneDomain() {
trace := Trace{
ARecord: []*DnsARecord{
&DnsARecord{
AddressId: proto.Int32(0),
Anonymized: proto.Bool(false),
Domain: proto.String("m.domain"),
},
},
}
traces := map[string]Trace{
string(lex.EncodeOrDie("node1", "anon1", int64(0), int32(0))): trace,
}
consistentRanges := []*store.Record{
&store.Record{
Key: lex.EncodeOrDie("node1", "anon1", int64(0), int32(0)),
Value: lex.EncodeOrDie("node1", "anon1", int64(0), int32(0)),
},
}
addressIdStore := map[string]string{
string(lex.EncodeOrDie("node1", "anon1", int64(0), int32(0), int32(0))): string(lex.EncodeOrDie("mac1")),
}
runLookupsPerDevicePipeline(traces, consistentRanges, addressIdStore)
// Output:
// LookupsPerDevice:
// node1,mac1,m.domain: 1
//
// LookupsPerDevicePerHour:
// node1,mac1,m.domain,0: 1
}
示例13: Close
func (w protobufStreamWriter) Close() error {
_, err := protocol.Messages(&protocol.StreamChunk{
EOF: proto.Bool(true),
}).WriteTo(w.conn)
return err
}
示例14: StatFile
func StatFile(name string, hash_it bool) (*contester_proto.FileStat, error) {
result := &contester_proto.FileStat{}
result.Name = &name
info, err := os.Stat(name)
if err != nil {
// Handle ERROR_FILE_NOT_FOUND - return no error and nil instead of stat struct
if IsStatErrorFileNotFound(err) {
return nil, nil
}
return nil, NewError(err, "statFile", "os.Stat")
}
if info.IsDir() {
result.IsDirectory = proto.Bool(true)
} else {
result.Size = proto.Uint64(uint64(info.Size()))
if hash_it {
checksum, err := HashFileString(name)
if err != nil {
return nil, NewError(err, "statFile", "hashFile")
}
result.Checksum = &checksum
}
}
return result, nil
}
示例15: HandleClientBuildGroup
// 客戶端申請建立討論組
func HandleClientBuildGroup(conn *net.TCPConn, recPacket *packet.Packet) {
// read
readMsg := &pb.PbClientBuildGroup{}
packet.Unpack(recPacket, readMsg)
uuid := ConnMapUuid.Get(conn).(string)
group_name := readMsg.GetGroupName()
// 建立討論組
ret, group_id := groupinfo.BuildGroup(group_name, uuid)
tips_msg := "討論組[" + group_name + "]建立成功"
if ret {
tips_msg = "討論組[" + group_name + "]建立失敗"
}
// write
writeMsg := &pb.PbServerNotifyBuildGroup{
Build: proto.Bool(ret),
GroupId: proto.String(group_id),
GroupName: proto.String(group_name),
OwnerUuid: proto.String(uuid),
TipsMsg: proto.String(tips_msg),
Timestamp: proto.Int64(time.Now().Unix()),
}
SendPbData(conn, packet.PK_ServerNotifyBuildGroup, writeMsg)
}