Go语言生成GUID和UUID

1.安装

go get -u github.com/timespacegroup/go-utils
import (
    "github.com/timespacegroup/go-utils"
)
使用,例:fieldNames := tsgutils.NewInterfaceBuilder()

1.生成GUID

func TestGUID(t *testing.T) {
    FmtPrintln("GUID: " + GUID())
}
结果: GUID: 80509ffeb2ac2aa8abf9126319cb719c

2.生成UUID

func TestUUID(t *testing.T) {
    FmtPrintln("UUID: " + UUID())
}
结果: UUID: 6b2cfd01-2466-e51b-d90a-a72ef662b9e2

3.GitHub源码地址

https://github.com/timespacegroup/go-utils
https://github.com/timespacegroup/go-utils/blob/master/id_generator.go

猜你喜欢

转载自blog.csdn.net/typa01_kk/article/details/80143481