go.uuid

Go 的 UUID 包。(UUID package for Go)

  • Owner: satori/go.uuid
  • Platform: Linux, Mac, Windows
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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

Main metrics

Overview
Name With Ownersatori/go.uuid
Primary LanguageGo
Program languageGo (Language Count: 1)
PlatformLinux, Mac, Windows
License:MIT License
所有者活动
Created At2013-06-18 07:58:05
Pushed At2024-08-10 05:37:14
Last Commit At2018-10-28 12:50:25
Release Count3
Last Release Namev1.2.0 (Posted on 2018-01-10 19:01:39)
First Release Namev1.0.0 (Posted on 2016-04-06 00:49:01)
用户参与
Stargazers Count4.9k
Watchers Count95
Fork Count599
Commits Count148
Has Issues Enabled
Issues Count64
Issue Open Count30
Pull Requests Count20
Pull Requests Open Count13
Pull Requests Close Count26
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

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.