uuuid

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: MIT Imports: 6 Imported by: 40

README

Universal Universally Unique ID


A UUID package that implements/will-implement required Marshalling/Unmarshalling interfaces for various types.

Based on github.com/gofrs/uuid.

Why?

It has been a source of great pain and inconvenience for my lazy existence, that the UUIDs have to be converted again and again to different types for operations such as inserting/fetching from Databases.

Enough. Not any more.


Currently implemented Marshal/Unmarshal interfaces

  • Go-CQL

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TimestampFromV1 added in v1.2.0

func TimestampFromV1(u UUID) (uuid.Timestamp, error)

TimestampFromV1 returns the Timestamp embedded within a V1 UUID. Returns an error if the UUID is any version other than 1.

Types

type UUID

type UUID struct {
	uuid.UUID
}

UUID represents a v4 UUID.

func FromBytes

func FromBytes(input []byte) (UUID, error)

FromBytes returns a UUID generated from the raw byte slice input. It will return an error if the slice isn't 16 bytes long.

func FromBytesOrNil

func FromBytesOrNil(input []byte) UUID

FromBytesOrNil returns a UUID generated from the raw byte slice input. Same behavior as FromBytes(), but returns uuid.Nil instead of an error.

func FromString

func FromString(input string) (UUID, error)

FromString returns a UUID parsed from the input string. Input is expected in a form accepted by UnmarshalText.

func FromStringOrNil

func FromStringOrNil(input string) UUID

FromStringOrNil returns a UUID parsed from the input string. Same behavior as FromString(), but returns uuid.Nil instead of an error.

func NewV1 added in v1.1.0

func NewV1() (UUID, error)

NewV1 returns a new v1 UUID

func NewV4

func NewV4() (UUID, error)

NewV4 returns a new v4 UUID

func (UUID) MarshalCQL

func (u UUID) MarshalCQL(info gocql.TypeInfo) ([]byte, error)

MarshalCQL converts the uuid into GoCql-compatible []byte.

func (*UUID) UnmarshalCQL

func (u *UUID) UnmarshalCQL(info gocql.TypeInfo, data []byte) error

UnmarshalCQL converts GoCql UUID-type to local UUID.

Jump to

Keyboard shortcuts

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