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
派生數599
提交數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.