當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。