Golang中UUID4的整数预表示

Fre*_*tor 5 python uuid go

我正在尝试在Golang中解析UUID4,但我需要一些特定的信息:Integer表示.

在python中我使用:

uuid.uuid4().int 
Run Code Online (Sandbox Code Playgroud)

但是在Golang中它不存在(或者我用Google搜索的任何其他uuid库).

有没有办法将简单的UUID解析为其整数表示?

One*_*One 8

假设你的uuid类型是一个字符串:

func main() {
    uuid := `25f64dba-634d-4613-9516-9ca61b161454`
    var i big.Int
    i.SetString(strings.Replace(uuid, "-", "", 4), 16)
    //or if your uuid is [16]byte
    //i.SetBytes(uuid[:])
    fmt.Println(i.String())
}
Run Code Online (Sandbox Code Playgroud)

playground