Categorygithub.com/fossoreslp/go-uuid-v4
modulepackage
1.0.0
Repository: https://github.com/fossoreslp/go-uuid-v4.git
Documentation: pkg.go.dev

# README

Go UUIDv4

CircleCI Coveralls Codacy Licensed under: Boost Software License GoDoc

This package contains a minimal implementation of UUIDv4 in Go.

Consider using either Google's implementation or this one by Gofrs if you need additional features.

This package can only generate version 4 UUIDs as defined in RFC 4122

Create a new UUID: uuid.New() (UUID, error)

Convert an UUID to a string: UUID.String() string

Do both in one step: uuid.NewString() (string, error)

Convert a string to an UUID: uuid.Parse(string) (UUID, error)

Convert a byte slice to an UUID: uuid.ParseBytes([]byte) (UUID, error)

Check if UUID contains only zeros: UUID.IsEmpty() bool

Both encoding.Text(Un)Marshaler and encoding.Binary(Un)Marshaler are supported to ensure compatibility with databases and data exchange formats.

# Functions

New generates a new UUID v4 using a secure random number generator chosen by GoLang.
NewString generates a new UUID v4 and converts it to a string immediately.
Parse parses a string as a UUID returning either the resulting UUID or an error.
ParseBytes parses a byte slice and returns the contained BINARY UUID or an error.

# Type aliases

UUID represents a Universal Unique Identifier as an array containing 16 bytes.