• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang uuid.UUID函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang uuid.UUID类代码示例发布时间:2022-05-23
下一篇:
Golang uuid.NewV4函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap