當前位置: 首頁>>代碼示例>>Golang>>正文


Golang uuid.UUID函數代碼示例

本文整理匯總了Golang中github.com/cockroachdb/cockroach/util/uuid.UUID函數的典型用法代碼示例。如果您正苦於以下問題:Golang UUID函數的具體用法?Golang UUID怎麽用?Golang UUID使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了UUID函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: String

// String formats transaction into human readable string.
func (t Transaction) String() string {
	// Compute priority as a floating point number from 0-100 for readability.
	floatPri := 100 * float64(t.Priority) / float64(math.MaxInt32)
	if len(t.Name) > 0 {
		return fmt.Sprintf("%q id=%s key=%s pri=%.8f iso=%s stat=%s epo=%d ts=%s orig=%s max=%s",
			t.Name, uuid.UUID(t.ID).Short(), t.Key, floatPri, t.Isolation, t.Status, t.Epoch, t.Timestamp, t.OrigTimestamp, t.MaxTimestamp)
	}
	return fmt.Sprintf("id=%s key=%s pri=%.8f iso=%s stat=%s epo=%d ts=%s orig=%s max=%s",
		uuid.UUID(t.ID).Short(), t.Key, floatPri, t.Isolation, t.Status, t.Epoch, t.Timestamp, t.OrigTimestamp, t.MaxTimestamp)
}
開發者ID:Gardenya,項目名稱:cockroach,代碼行數:11,代碼來源:data.go

示例2: TraceID

// TraceID implements tracer.Traceable. For a nontrivial Transaction, it
// returns 't', followed by the transaction ID. Otherwise, the empty string is
// returned.
func (t *Transaction) TraceID() string {
	if t == nil || len(t.ID) == 0 {
		return ""
	}
	s := uuid.UUID(t.ID).String()
	return "t" + s
}
開發者ID:mbertschler,項目名稱:cockroach,代碼行數:10,代碼來源:data.go

示例3: TestUUIDString

func TestUUIDString(t *testing.T) {
	uuid := uuid.UUID([]byte("ת\x0f^\xe4-Fؽ\xf7\x16\xe4\xf9\xbe^\xbe"))
	expStr := "d7aa0f5e-e42d-46d8-bdf7-16e4f9be5ebe"
	if str := uuid.String(); str != expStr {
		t.Errorf("expected txn %s; got %s", expStr, str)
	}
}
開發者ID:Gardenya,項目名稱:cockroach,代碼行數:7,代碼來源:uuid_test.go

示例4: String

// String formats transaction into human readable string.
func (t Transaction) String() string {
	var buf bytes.Buffer
	// Compute priority as a floating point number from 0-100 for readability.
	floatPri := 100 * float64(t.Priority) / float64(math.MaxInt32)
	if len(t.Name) > 0 {
		fmt.Fprintf(&buf, "%q ", t.Name)
	}
	fmt.Fprintf(&buf, "id=%s key=%s rw=%t pri=%.8f iso=%s stat=%s epo=%d ts=%s orig=%s max=%s",
		uuid.UUID(t.ID).Short(), t.Key, t.Writing, floatPri, t.Isolation, t.Status, t.Epoch, t.Timestamp, t.OrigTimestamp, t.MaxTimestamp)
	return buf.String()
}
開發者ID:mbertschler,項目名稱:cockroach,代碼行數:12,代碼來源:data.go

示例5: Short

// Short returns the short form of the Transaction's UUID.
func (t Transaction) Short() string {
	return uuid.UUID(t.ID).Short()
}
開發者ID:mbertschler,項目名稱:cockroach,代碼行數:4,代碼來源:data.go

示例6: Short

// Short returns the short form of the Transaction's UUID.
func (t *Transaction) Short() string {
	return uuid.UUID(t.GetID()).Short()
}
開發者ID:Gardenya,項目名稱:cockroach,代碼行數:4,代碼來源:data.go

示例7: init

func init() {
	incR := roachpb.IncrementResponse{
		NewValue: 1,
	}
	batchR.Add(&incR)
}

// createTestSequenceCache creates an in-memory engine and
// returns a sequence cache using the supplied Range ID.
func createTestSequenceCache(t *testing.T, rangeID roachpb.RangeID, stopper *stop.Stopper) (*SequenceCache, engine.Engine) {
	return NewSequenceCache(rangeID), engine.NewInMem(roachpb.Attributes{}, 1<<20, stopper)
}

const testTxnEpoch = 5

var testTxnID = uuid.UUID([]byte("0ce61c17-5eb4-4587-8c36-dcf4062ada4c"))
var testTxnKey = []byte("a")
var testTxnTimestamp = roachpb.ZeroTimestamp.Add(123, 456)
var testEntry = roachpb.SequenceCacheEntry{Key: testTxnKey, Timestamp: testTxnTimestamp}

func TestSequenceCacheEncodeDecode(t *testing.T) {
	defer leaktest.AfterTest(t)
	const rangeID = 123
	const expSeq = 987
	key := keys.SequenceCacheKey(rangeID, testTxnID, testTxnEpoch, expSeq)
	id, epoch, seq, err := decodeSequenceCacheKey(key, nil)
	if err != nil {
		t.Fatal(err)
	}
	if !bytes.Equal(id, testTxnID) {
		t.Fatalf("expected id %q, got %q", testTxnID, id)
開發者ID:kaustubhkurve,項目名稱:cockroach,代碼行數:31,代碼來源:sequence_cache_test.go


注:本文中的github.com/cockroachdb/cockroach/util/uuid.UUID函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。