uuid

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

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

Go to latest
Published: May 25, 2020 License: MIT Imports: 6 Imported by: 0

README

go-uuid

go-uuid is a library that implements UUIDs in Go. It supports writing and reading from SQL databases. If you require a more fully featured library, I would reccomend Google's UUID library. However I have found this smaller library to be more than sufficent thus far.

Documentation

Documentation can be found at pkg.go.dev.

Testing

This library can be tested with

go test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(u1, u2 UUID) bool

Equal returns true if the two UUIDs are equal.

Types

type UUID

type UUID [16]byte

A UUID is a 16 byte Universally Unqiue Identifier as defined in RFC4122.

func Must

func Must() UUID

Must behaves the same as New, but catches any errors that occur and panics. This simplifies declaration and initlization.

func New

func New() (UUID, error)

New returns a random V4 UUID.

func Parse

func Parse(src interface{}) (UUID, error)

Parse decodes string s into a UUID or returns an error. It currently only supports UUIDs in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

func (UUID) Bytes

func (uuid UUID) Bytes() []byte

Bytes returns the underlying bytes the UUID represents.

func (UUID) MarshalText

func (uuid UUID) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*UUID) Scan

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

Scan implements the sql.Scanner interface so that UUIDs can be read from databases so support SQL operations.

func (UUID) String

func (uuid UUID) String() string

String implements the Stringer interface and returns the UUID in the form of: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

func (*UUID) UnmarshalText

func (uuid *UUID) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (UUID) Value

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

Value implements the sql.Valuer so that UUIDs can be written to databases to support SQL operations.

Jump to

Keyboard shortcuts

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