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


Golang uuid.UUID類代碼示例

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


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

示例1: TransactionKey

// TransactionKey returns a transaction key based on the provided
// transaction key and ID. The base key is encoded in order to
// guarantee that all transaction records for a range sort together.
func TransactionKey(key roachpb.Key, txnID *uuid.UUID) roachpb.Key {
	rk, err := Addr(key)
	if err != nil {
		panic(err)
	}
	return MakeRangeKey(rk, localTransactionSuffix, roachpb.RKey(txnID.GetBytes()))
}
開發者ID:knz,項目名稱:cockroach,代碼行數:10,代碼來源:keys.go

示例2: fillUUID

func fillUUID(b byte) uuid.UUID {
	var ret uuid.UUID
	for i := range ret.GetBytes() {
		ret.UUID[i] = b
	}
	return ret
}
開發者ID:hvaara,項目名稱:cockroach,代碼行數:7,代碼來源:abort_cache.go

示例3: assertTS

// assertTS is a helper function for layeredIntervalTestCase
// validators. It queries the timestamp cache for the given keys and
// reports a test error if it doesn't match the given timestamp and
// transaction ID.
func assertTS(
	t *testing.T,
	tc *timestampCache,
	start, end roachpb.Key,
	expectedTS hlc.Timestamp,
	expectedTxnID *uuid.UUID,
) {
	var keys string
	if len(end) == 0 {
		keys = fmt.Sprintf("%q", start)
	} else {
		keys = fmt.Sprintf("%q-%q", start, end)
	}
	ts, txnID, _ := tc.GetMaxRead(start, end)
	if !ts.Equal(expectedTS) {
		t.Errorf("expected %s to have timestamp %v, found %v", keys, expectedTS, ts)
	}
	if expectedTxnID == nil {
		if txnID != nil {
			t.Errorf("expected %s to have no txn id, but found %s", keys, txnID.Short())
		}
	} else {
		if txnID == nil {
			t.Errorf("expected %s to have txn id %s, but found nil", keys, expectedTxnID.Short())
		} else if *txnID != *expectedTxnID {
			t.Errorf("expected %s to have txn id %s, but found %s",
				keys, expectedTxnID.Short(), txnID.Short())
		}
	}
}
開發者ID:hvaara,項目名稱:cockroach,代碼行數:34,代碼來源:timestamp_cache_test.go

示例4: AbortCacheKey

// AbortCacheKey returns a range-local key by Range ID for an
// abort cache entry, with detail specified by encoding the
// supplied transaction ID.
func AbortCacheKey(rangeID roachpb.RangeID, txnID *uuid.UUID) roachpb.Key {
	key := MakeRangeIDReplicatedKey(rangeID, LocalAbortCacheSuffix, nil)
	key = encoding.EncodeBytesAscending(key, txnID.GetBytes())
	return key
}
開發者ID:knz,項目名稱:cockroach,代碼行數:8,代碼來源:keys.go


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