当前位置: 首页>>代码示例>>Golang>>正文


Golang proto.CompactTextString函数代码示例

本文整理汇总了Golang中code/google/com/p/goprotobuf/proto.CompactTextString函数的典型用法代码示例。如果您正苦于以下问题:Golang CompactTextString函数的具体用法?Golang CompactTextString怎么用?Golang CompactTextString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CompactTextString函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestGetDupSuppressProto

// tests that a Getter's Get method is only called once with two
// outstanding callers.  This is the proto variant.
func TestGetDupSuppressProto(t *testing.T) {
	once.Do(testSetup)
	// Start two getters. The first should block (waiting reading
	// from stringc) and the second should latch on to the first
	// one.
	resc := make(chan *testpb.TestMessage, 2)
	for i := 0; i < 2; i++ {
		go func() {
			tm := new(testpb.TestMessage)
			if err := protoGroup.Get(dummyCtx, fromChan, ProtoSink(tm)); err != nil {
				tm.Name = proto.String("ERROR:" + err.Error())
			}
			resc <- tm
		}()
	}

	// Wait a bit so both goroutines get merged together via
	// singleflight.
	// TODO(bradfitz): decide whether there are any non-offensive
	// debug/test hooks that could be added to singleflight to
	// make a sleep here unnecessary.
	time.Sleep(250 * time.Millisecond)

	// Unblock the first getter, which should unblock the second
	// as well.
	stringc <- "Fluffy"
	want := &testpb.TestMessage{
		Name: proto.String("ECHO:Fluffy"),
		City: proto.String("SOME-CITY"),
	}
	for i := 0; i < 2; i++ {
		select {
		case v := <-resc:
			if !reflect.DeepEqual(v, want) {
				t.Errorf(" Got: %v\nWant: %v", proto.CompactTextString(v), proto.CompactTextString(want))
			}
		case <-time.After(5 * time.Second):
			t.Errorf("timeout waiting on getter #%d of 2", i+1)
		}
	}
}
开发者ID:hefju,项目名称:groupcache,代码行数:43,代码来源:groupcache_test.go

示例2: main

func main() {
	p := Person{
		Name: proto.String("Taro Yamada"),
		Age:  proto.Int32(8),
	}

	pet := Pet{Name: proto.String("Mike")}
	p.Pet = append(p.Pet, &pet)
	fmt.Println("-- p.String()  --")
	fmt.Println(p.String())
	fmt.Println("-- MarshalText --")
	fmt.Print(PrintToString(&p)) // not compact

	fmt.Println("-- Marshal --")
	m, _ := proto.Marshal(&p)
	fmt.Println(m)

	fmt.Println("-- CompactTextString --")
	fmt.Println(proto.CompactTextString(&p))
}
开发者ID:yunabe,项目名称:codelab,代码行数:20,代码来源:protobuf.go

示例3: String

func (this *request) String() string { return proto.CompactTextString(this) }
开发者ID:dcjones,项目名称:doozer,代码行数:1,代码来源:msg.pb.go

示例4: String

func (m *URLFetchResponse) String() string { return proto.CompactTextString(m) }
开发者ID:LeXa4894,项目名称:test,代码行数:1,代码来源:urlfetch_service.pb.go

示例5: String

func (m *MgxBidRequest) String() string { return proto.CompactTextString(m) }
开发者ID:brg-liuwei,项目名称:dspHelloWorld,代码行数:1,代码来源:request.pb.go

示例6: String

func (m *RenewDelegationTokenRequestProto) String() string { return proto.CompactTextString(m) }
开发者ID:hortonworks,项目名称:kubernetes-yarn,代码行数:1,代码来源:Security.pb.go

示例7: String

func (m *Attribute) String() string { return proto.CompactTextString(m) }
开发者ID:nekto0n,项目名称:gomes,代码行数:1,代码来源:mesos.pb.go

示例8: String

func (m *Entry) String() string { return proto.CompactTextString(m) }
开发者ID:hardiku,项目名称:gozer,代码行数:1,代码来源:state.pb.go

示例9: String

func (this *VoiceModeControl) String() string { return proto.CompactTextString(this) }
开发者ID:botaydotcom,项目名称:GoMessagingTestFrameWork,代码行数:1,代码来源:CommonProtocol.pb.go

示例10: String

func (this *SumMessage) String() string { return proto.CompactTextString(this) }
开发者ID:pguelpa,项目名称:go-rpcgen,代码行数:1,代码来源:addservice.pb.go

示例11: String

func (m *Forward) String() string { return proto.CompactTextString(m) }
开发者ID:jbeshir,项目名称:unanimity,代码行数:1,代码来源:rproto.pb.go


注:本文中的code/google/com/p/goprotobuf/proto.CompactTextString函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。