uuid7

package module
v0.0.0-...-a2de7bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2025 License: Apache-2.0 Imports: 9 Imported by: 8

README

uuid7

Documentation: https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-03

Example

package main

import (
    "log"

    "github.com/GoWebProd/uuid7"
)

func main() {
    u := uuid7.New()

    log.Println(u.Next().String())
}

Benchmark

goos: linux
goarch: amd64
pkg: github.com/GoWebProd/uuid7
cpu: Intel Xeon Processor (Skylake, IBRS)
BenchmarkNext-8         18314782                65.94 ns/op            0 B/op          0 allocs/op
BenchmarkString-8       17735802                67.66 ns/op           48 B/op          1 allocs/op
BenchmarkParse-8        14948330                78.38 ns/op            0 B/op          0 allocs/op
PASS
ok      github.com/GoWebProd/uuid7      3.812s

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadUUID    = errors.New("bad UUID")
	ErrBadVersion = errors.New("bad UUID version")
)

Functions

This section is empty.

Types

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func New

func New() *Generator

func (*Generator) Next

func (u *Generator) Next() UUID

func (*Generator) NextWithTimestamp

func (u *Generator) NextWithTimestamp(ts int64) UUID

Timestamp in milliseconds

type UUID

type UUID [16]byte

func From

func From(cnt uint32, rnd1 uint64, rnd2 uint64, ts int64) UUID

func MustParse

func MustParse(s string) UUID

func Parse

func Parse(uuid string) (UUID, error)

func (UUID) Empty

func (u UUID) Empty() bool

func (*UUID) Scan

func (uuid *UUID) Scan(src interface{}) error

func (UUID) String

func (u UUID) String() string

func (UUID) Timestamp

func (u UUID) Timestamp() uint64

func (UUID) Value

func (uuid UUID) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL