Documentation ¶
Overview ¶
The Tideland Go Library identifier package provides different ways to produce identifiers out of diffent input data as well as UUIDs.
The UUID generation can be done according the versions 1, 3, 4, and 5. Other identifier types are based on passed data or types. Here the individual parts are harmonized and concatenated by the passed seperators. It is the users responsibility to check if the identifier is unique in its context.
Index ¶
- Constants
- func Identifier(parts ...interface{}) string
- func IsInvalidHexLengthError(err error) bool
- func IsInvalidHexValueError(err error) bool
- func JoinedIdentifier(identifiers ...string) string
- func LimitedSepIdentifier(sep string, limit bool, parts ...interface{}) string
- func PackageVersion() version.Version
- func SepIdentifier(sep string, parts ...interface{}) string
- func TypeAsIdentifierPart(i interface{}) string
- type UUID
- func NewUUID() UUID
- func NewUUIDByHex(source string) (UUID, error)
- func NewUUIDv1() (UUID, error)
- func NewUUIDv3(ns UUID, name []byte) (UUID, error)
- func NewUUIDv4() (UUID, error)
- func NewUUIDv5(ns UUID, name []byte) (UUID, error)
- func UUIDNamespaceDNS() UUID
- func UUIDNamespaceOID() UUID
- func UUIDNamespaceURL() UUID
- func UUIDNamespaceX500() UUID
Constants ¶
const ( ErrInvalidHexLength = iota + 1 ErrInvalidHexValue )
Variables ¶
This section is empty.
Functions ¶
func Identifier ¶
func Identifier(parts ...interface{}) string
Identifier works like SepIdentifier but the seperator is set to be a colon.
func IsInvalidHexLengthError ¶
IsInvalidHexLengthError returns true, if the error signals that the passed hex string for a UUID hasn't the correct size of 32.
func IsInvalidHexValueError ¶
IsInvalidHexValueError returns true, if the error signals an invalid hex string as input.
func JoinedIdentifier ¶
JoinedIdentifier builds a new identifier, joinded with the colon as the seperator.
func LimitedSepIdentifier ¶
LimitedSepIdentifier builds an identifier out of multiple parts, all as lowercase strings and concatenated with the separator Non letters and digits are exchanged with dashes and reduced to a maximum of one each. If limit is true only 'a' to 'z' and '0' to '9' are allowed.
func PackageVersion ¶
PackageVersion returns the version of the version package.
func SepIdentifier ¶
SepIdentifier builds an identifier out of multiple parts, all as lowercase strings and concatenated with the separator Non letters and digits are exchanged with dashes and reduced to a maximum of one each.
func TypeAsIdentifierPart ¶
func TypeAsIdentifierPart(i interface{}) string
TypeAsIdentifierPart transforms the name of the arguments type into a part for identifiers. It's splitted at each uppercase char, concatenated with dashes and transferred to lowercase.
Types ¶
type UUID ¶
type UUID [16]byte
UUID represents a universal identifier with 16 bytes. See http://en.wikipedia.org/wiki/Universally_unique_identifier.
func NewUUIDByHex ¶
NewUUIDByHex creates a UUID based on the passed hex string which has to have the length of 32 bytes.
func NewUUIDv3 ¶
NewUUIDv3 generates a new UUID based on version 3 (MD5 hash of a namespace and a name).
func NewUUIDv5 ¶
NewUUIDv5 generates a new UUID based on version 5 (SHA1 hash of a namespace and a name).
func UUIDNamespaceDNS ¶
func UUIDNamespaceDNS() UUID
UUIDNamespaceDNS returns the DNS namespace UUID.
func UUIDNamespaceOID ¶
func UUIDNamespaceOID() UUID
UUIDNamespaceOID returns the OID namespace UUID.
func UUIDNamespaceURL ¶
func UUIDNamespaceURL() UUID
UUIDNamespaceURL returns the URL namespace UUID.
func UUIDNamespaceX500 ¶
func UUIDNamespaceX500() UUID
UUIDNamespaceX500 returns the X.500 namespace UUID.