go.uuid

Go 的 UUID 包。(UUID package for Go)

  • 所有者: satori/go.uuid
  • 平台: Linux, Mac, Windows
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Go 语言的 UUID 包

这个包提供了通用唯一标识符(UUID)的纯 Go 实现。支持 UUID 的创建和解析。

100%的测试覆盖率和开箱即用的基准测试。

支持的版本:

  • 版本1,基于时间戳和MAC地址(RFC 4122)
  • 版本2,基于时间戳,MAC地址和POSIX UID / GID(DCE 1.1)
  • 版本3,基于MD5散列(RFC 4122)
  • 版本4,基于随机数(RFC 4122)
  • 版本5,基于SHA-1散列(RFC 4122)

安装

使用go命令:

$ go get github.com/satori/go.uuid

要求

UUID 包针对 Go>=1.6 进行了测试。

示例

package main
import (
    "fmt"
    "github.com/satori/go.uuid"
)
func main() {
    // Creating UUID Version 4
    // panic on error
    u1 := uuid.Must(uuid.NewV4())
    fmt.Printf("UUIDv4: %s\n", u1)
    // or error handling
    u2, err := uuid.NewV4()
    if err != nil {
        fmt.Printf("Something went wrong: %s", err)
        return
    }
    fmt.Printf("UUIDv4: %s\n", u2)
    // Parsing UUID from string input
    u2, err := uuid.FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
    if err != nil {
        fmt.Printf("Something went wrong: %s", err)
        return
    }
    fmt.Printf("Successfully parsed: %s", u2)
}

文档

文档托管在 GoDoc 项目中。

链接

版权

版权所有(C)2013-2018,作者:Maxim Bublis b@codemonkey.ru

UUID 包在 MIT License 下发布。 有关详细信息,请参阅 LICENSE

主要指标

概览
名称与所有者satori/go.uuid
主编程语言Go
编程语言Go (语言数: 1)
平台Linux, Mac, Windows
许可证MIT License
所有者活动
创建于2013-06-18 07:58:05
推送于2024-08-10 05:37:14
最后一次提交2018-10-28 12:50:25
发布数3
最新版本名称v1.2.0 (发布于 2018-01-10 19:01:39)
第一版名称v1.0.0 (发布于 2016-04-06 00:49:01)
用户参与
星数4.9k
关注者数95
派生数600
提交数148
已启用问题?
问题数64
打开的问题数30
拉请求数20
打开的拉请求数13
关闭的拉请求数26
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?

UUID package for Go language

Build Status
Coverage Status
GoDoc

This package provides pure Go implementation of Universally Unique Identifier (UUID). Supported both creation and parsing of UUIDs.

With 100% test coverage and benchmarks out of box.

Supported versions:

  • Version 1, based on timestamp and MAC address (RFC 4122)
  • Version 2, based on timestamp, MAC address and POSIX UID/GID (DCE 1.1)
  • Version 3, based on MD5 hashing (RFC 4122)
  • Version 4, based on random numbers (RFC 4122)
  • Version 5, based on SHA-1 hashing (RFC 4122)

Installation

Use the go command:

$ go get github.com/satori/go.uuid

Requirements

UUID package tested against Go >= 1.6.

Example

package main

import (
	"fmt"
	"github.com/satori/go.uuid"
)

func main() {
	// Creating UUID Version 4
	// panic on error
	u1 := uuid.Must(uuid.NewV4())
	fmt.Printf("UUIDv4: %s\n", u1)

	// or error handling
	u2, err := uuid.NewV4()
	if err != nil {
		fmt.Printf("Something went wrong: %s", err)
		return
	}
	fmt.Printf("UUIDv4: %s\n", u2)

	// Parsing UUID from string input
	u2, err := uuid.FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
	if err != nil {
		fmt.Printf("Something went wrong: %s", err)
		return
	}
	fmt.Printf("Successfully parsed: %s", u2)
}

Documentation

Documentation is hosted at GoDoc project.

Copyright (C) 2013-2018 by Maxim Bublis b@codemonkey.ru.

UUID package released under MIT License.
See LICENSE for details.