本文整理汇总了Golang中code/google/com/p/goprotobuf/proto.Bool函数的典型用法代码示例。如果您正苦于以下问题:Golang Bool函数的具体用法?Golang Bool怎么用?Golang Bool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Bool函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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),
}
}
开发者ID:kleopatra999,项目名称:appengine,代码行数:7,代码来源:xmpp_test.go
示例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)
}
开发者ID:sburnett,项目名称:bismark-passive-server-go,代码行数:35,代码来源:trace_test.go
示例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
}
开发者ID:LeXa4894,项目名称:test,代码行数:56,代码来源:query.go
示例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
}
开发者ID:kleopatra999,项目名称:appengine,代码行数:55,代码来源:query_test.go
示例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
}
开发者ID:rok-kek,项目名称:grumble,代码行数:15,代码来源:freeze.go
示例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
}
开发者ID:rok-kek,项目名称:grumble,代码行数:15,代码来源:freeze.go
示例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)
}
}
开发者ID:Zoramite,项目名称:ripple,代码行数:50,代码来源:peer.go
示例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
}
开发者ID:petemoore,项目名称:runlib,代码行数:32,代码来源:exec.go
示例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
}
开发者ID:zhjh1209,项目名称:a_game,代码行数:49,代码来源:duplicate.go
示例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
}
开发者ID:Kissaki,项目名称:grumble,代码行数:17,代码来源:freeze.go
示例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
}
开发者ID:LeXa4894,项目名称:test,代码行数:28,代码来源:taskqueue.go
示例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
}
开发者ID:sburnett,项目名称:bismark-passive-server-go,代码行数:32,代码来源:lookupsperdevice_test.go
示例13: Close
func (w protobufStreamWriter) Close() error {
_, err := protocol.Messages(&protocol.StreamChunk{
EOF: proto.Bool(true),
}).WriteTo(w.conn)
return err
}
开发者ID:vito,项目名称:warden-docker,代码行数:7,代码来源:stream_writer.go
示例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
}
开发者ID:petemoore,项目名称:runlib,代码行数:26,代码来源:stat.go
示例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)
}
开发者ID:cautonwong,项目名称:chatserver,代码行数:26,代码来源:group.go
示例16: createSubmit
func createSubmit(db *sqlx.DB, sub *scannedSubmit, submitNo int) *tickets.Ticket_Submit {
var result tickets.Ticket_Submit
result.SubmitNumber = proto.Uint32(uint32(submitNo))
if sub.Arrived > 0 {
result.Arrived = proto.Uint64(uint64(sub.Arrived))
}
if result.Compiled = proto.Bool(sub.Compiled == 1); !result.GetCompiled() {
return &result
}
if sub.SchoolMode != 0 {
result.School = &tickets.Ticket_Submit_School{TestsTaken: proto.Uint32(uint32(sub.Taken)), TestsPassed: proto.Uint32(uint32(sub.Passed))}
} else {
var description string
var test int64
err := db.QueryRow("select ResultDesc.Description, Results.Test from Results, ResultDesc where "+
"Results.UID = ? and ResultDesc.ID = Results.Result and not ResultDesc.Success order by Results.Test",
sub.TestingID).Scan(&description, &test)
switch {
case err == sql.ErrNoRows:
if sub.Passed != 0 && sub.Passed == sub.Taken {
result.Acm = &tickets.Ticket_Submit_ACM{Result: proto.String("ACCEPTED")}
}
case err != nil:
log.Fatal(err)
return nil
default:
result.Acm = &tickets.Ticket_Submit_ACM{Result: &description, TestId: proto.Uint32(uint32(test))}
}
}
return &result
}
开发者ID:petemoore,项目名称:printing3,代码行数:31,代码来源:ticket_grabber.go
示例17: Build
func (pkgr *Packager) Build() {
pkgr.resolveDependencies()
// add the submixer boundary info
// thisOffset := int32(len(pkgr.Mixer.Package.Functions))
// info := &tp.SubmixerInfo{
// Name: proto.String(pkgr.GetName()),
// Version: proto.String(pkgr.GetVersion()),
// Offset: proto.Int32(thisOffset),
// // set the length below
// }
pkgr.resolveTypeDeclarations()
pkgr.populateTypeList()
pkgr.buildLib()
// length of Functions array has changed; recompute it and subtract the last offset to get the length of this component
// info.Length = proto.Int32(int32(len(pkgr.Mixer.Package.Functions))-thisOffset)
// pkgr.Mixer.Submixers = append(pkgr.Mixer.Submixers, info)
if pkgr.IsHttpTransformer {
pkgr.Mixer.IsHttpTransformer = proto.Bool(true)
pkgr.Mixer.Rewriters = tp.CollectFiles(filepath.Join(pkgr.MixerDir, SCRIPTS_DIR))
if pkgr.Mixer.Package.Dependencies == nil {
pkgr.Mixer.Package.Dependencies = make([]string, 0)
}
for name, version := range pkgr.Dependencies {
pkgr.Mixer.Package.Dependencies = append(pkgr.Mixer.Package.Dependencies, fmt.Sprintf("%s:%s", name, version))
}
}
}
开发者ID:nmakiya,项目名称:tritium,代码行数:29,代码来源:packager.go
示例18: UpdateFrozenChannelACLs
// Write a channel's ACL and Group data to disk. Mumble doesn't support
// incremental ACL updates and as such we must write all ACLs and groups
// to the datastore on each change.
func (server *Server) UpdateFrozenChannelACLs(channel *Channel) {
fc := &freezer.Channel{}
fc.Id = proto.Uint32(uint32(channel.Id))
fc.InheritAcl = proto.Bool(channel.ACL.InheritACL)
acls := []*freezer.ACL{}
for _, aclEntry := range channel.ACL.ACLs {
facl, err := FreezeACL(aclEntry)
if err != nil {
return
}
acls = append(acls, facl)
}
fc.Acl = acls
groups := []*freezer.Group{}
for _, grp := range channel.ACL.Groups {
fgrp, err := FreezeGroup(grp)
if err != nil {
return
}
groups = append(groups, fgrp)
}
fc.Groups = groups
err := server.freezelog.Put(fc)
if err != nil {
server.Fatal(err)
}
server.numLogOps += 1
}
开发者ID:rok-kek,项目名称:grumble,代码行数:35,代码来源:freeze.go
示例19: Stop
func (c *connection) Stop(handle string, background, kill bool) error {
err := c.roundTrip(
&protocol.StopRequest{
Handle: proto.String(handle),
Background: proto.Bool(background),
Kill: proto.Bool(kill),
},
&protocol.StopResponse{},
)
if err != nil {
return err
}
return nil
}
开发者ID:vito,项目名称:warden-linux,代码行数:16,代码来源:connection.go
示例20: HandleClientLogin
// 客户端登陆
func HandleClientLogin(conn *net.TCPConn, recPacket *packet.Packet) {
// read
readMsg := &pb.PbClientLogin{}
packet.Unpack(recPacket, readMsg)
uuid := readMsg.GetUuid()
// 检测uuid合法性
if cid.UuidCheckExist(uuid) {
// 如果已经在线则关闭以前的conn
if cid.UuidCheckOnline(uuid) {
co := UuidMapConn.Get(uuid)
if co != nil {
CloseConn(co.(*net.TCPConn))
}
}
// 上线conn
InitConn(conn, uuid)
} else {
CloseConn(conn)
}
// fmt.Println("uuid:", readMsg.GetUuid())
// fmt.Println("version:", readMsg.GetVersion())
// fmt.Println("timestamp:", convert.TimestampToTimeString(readMsg.GetTimestamp()))
// write
writeMsg := &pb.PbServerAcceptLogin{
Login: proto.Bool(true),
TipsMsg: proto.String("登陆成功"),
Timestamp: proto.Int64(time.Now().Unix()),
}
SendPbData(conn, packet.PK_ServerAcceptLogin, writeMsg)
}
开发者ID:cautonwong,项目名称:chatserver,代码行数:35,代码来源:handler.go
注:本文中的code/google/com/p/goprotobuf/proto.Bool函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论