github.com/fossoreslp/go-uuid-v4

Small package implementing UUIDv4 in go with a few basic functions


Keywords
golang, uuid, rfc4122, uuid4, uuidv4
License
BSL-1.0
Install
go get github.com/fossoreslp/go-uuid-v4

Documentation

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.