system

package
v0.0.0-...-7ece020 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2016 License: GPL-3.0 Imports: 8 Imported by: 39

Documentation

Index

Constants

View Source
const (
	// VariantNCSCompat defines
	VariantNCSCompat = 0

	// VariantIETF defines
	VariantIETF = 2

	// VariantMicrosoft defines
	VariantMicrosoft = 6

	// VariantFuture defines
	VariantFuture = 7
)

Variables

View Source
var EmptyUUID = UUID{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

EmptyUUID represents an empty UUID

Functions

This section is empty.

Types

type UUID

type UUID [16]byte

UUID represents an identifier standard used in software construction. A UUID is simply a 128-bit value. The meaning of each bit is defined by any of several variants.

func ParseUUID

func ParseUUID(input string) (UUID, error)

ParseUUID parses a 32 digit hexadecimal number (that might contain hypens) representing an UUID.

func RandomUUID

func RandomUUID() (UUID, error)

RandomUUID generates a totally random UUID (version 4) as described in RFC 4122.

func TimeUUID

func TimeUUID() UUID

TimeUUID generates a new time based UUID (version 1) using the current time as the timestamp.

func UUIDFromBytes

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

UUIDFromBytes converts a raw byte slice to an UUID.

func UUIDFromTime

func UUIDFromTime(aTime time.Time) UUID

UUIDFromTime generates a new time based UUID (version 1) as described in RFC 4122. This UUID contains the MAC address of the node that generated the UUID, the given timestamp and a sequence number.

func (UUID) Bytes

func (u UUID) Bytes() []byte

Bytes returns the raw byte slice for this UUID. A UUID is always 128 bits (16 bytes) long.

func (UUID) MarshalJSON

func (u UUID) MarshalJSON() ([]byte, error)

MarshalJSON Marshaling for JSON

func (UUID) MarshalText

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

MarshalText marshaling for text

func (UUID) Node

func (u UUID) Node() []byte

Node extracts the MAC address of the node who generated this UUID. It will return nil if the UUID is not a time based UUID (version 1).

func (UUID) String

func (u UUID) String() string

String returns the UUID in it's canonical form, a 32 digit hexadecimal number in the form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

func (UUID) Time

func (u UUID) Time() time.Time

Time is like Timestamp, except that it returns a time.Time.

func (UUID) Timestamp

func (u UUID) Timestamp() int64

Timestamp extracts the timestamp information from a time based UUID (version 1).

func (*UUID) UnmarshalJSON

func (u *UUID) UnmarshalJSON(data []byte) error

UnmarshalJSON Unmarshaling for JSON

func (*UUID) UnmarshalText

func (u *UUID) UnmarshalText(text []byte) (err error)

UnmarshalText unmarshalling for text

func (UUID) Variant

func (u UUID) Variant() int

Variant returns the variant of this UUID. This package will only generate UUIDs in the IETF variant.

func (UUID) Version

func (u UUID) Version() int

Version extracts the version of this UUID variant. The RFC 4122 describes five kinds of UUIDs.

type UUIDGeneratorService

type UUIDGeneratorService interface {
	// Generates random UUID value.
	// Either the new random generated UUID or an error if something goes wrong.
	GenerateRandomUUID() (UUID, error)
}

UUIDGeneratorService defines the interface that will generate random UUID, will be used to inject UUID generator service implementation to different services.

type UUIDGeneratorServiceImpl

type UUIDGeneratorServiceImpl struct {
}

UUIDGeneratorServiceImpl is the default implementation of UUID generator service

func (UUIDGeneratorServiceImpl) GenerateRandomUUID

func (UUIDGeneratorServiceImpl) GenerateRandomUUID() (UUID, error)

GenerateRandomUUID generates random UUID value. Returns either the new random generated UUID or an error if something goes wrong.

Jump to

Keyboard shortcuts

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