uuid

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

README

UUID

UUID implementation for Go, using a couple uint64 to represent it.


UUID

The *UUID structure with some methods to work with uuids

Usage

UUID

  • Equal - Check if the given uuid equals.
  • MarshalBinary - Marshal the uuid into a byte array.
  • UnmarshalBinary - Unmarshal the byte array into uuid.
  • String - A string representation of the uuid.

V4

Generates a new uuid v4 using math/rand/v2 and returns *UUID
New is the same as calling V4

V7

Generates a new uuid v7 using time and math/rand/v2 and returns *UUID

Example

package main

import (
	"fmt"
	"github.com/Dviih/uuid"
)

func main() {
	fmt.Println(uuid.New())
}

Made for Gophers by @Dviih

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidLength = errors.New("invalid length")

Functions

This section is empty.

Types

type UUID

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

func New

func New() *UUID

func V4

func V4() *UUID

func V7

func V7() *UUID

func (*UUID) Equal

func (uuid *UUID) Equal(equal *UUID) bool

func (*UUID) MarshalBinary

func (uuid *UUID) MarshalBinary() ([]byte, error)

func (*UUID) String

func (uuid *UUID) String() string

func (*UUID) UnmarshalBinary

func (uuid *UUID) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

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