util

package
v0.0.0-...-0aebffb Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RegexUuid = regexp.MustCompilePOSIX(reUuidStr)
)

Functions

func BindHost

func BindHost() string

func IsEmailLike

func IsEmailLike(subject string) bool

Returns whether a subject string looks like an email

func IsUuidLike

func IsUuidLike(subject string) bool

Returns whether a subject string looks like a UUID

func Uuid1OrderedChar32

func Uuid1OrderedChar32() string

Returns a new "ordered" UUID1 as 32 alphanumeric characters with no dashes -- the most efficient string representation for storage in a DB (besides storing as BINARY, which makes querying ugly and overly difficult for little benefit)

Returns a UUID type 1 value, with the more constant segments of the UUID at the start of the UUID. This allows us to have mostly monotonically increasing UUID values, which are much better for INSERT/UPDATE performance in the DB.

A UUID1 hex looks like:

'27392da28bae11e4961de06995034837'

From this, we need to take the last two segments, which represent the more constant information about the node we're on, and place those first in the new UUID's bytes. We then take the '11e4' segment, which represents the most significant bits of the timestamp part of the UUID, prefixed with a '1' for UUID type, and place that next, followed by the second segment and finally the first segment, which are the next most significant bits of the timestamp 60-bit number embedded in the UUID.

So, we convert the above hex to this instead:

'961de0699503483711e48bae27392da2'

func Uuid4Char32

func Uuid4Char32() string

Returns a 32-character string UUID4 value

func UuidFormatDb

func UuidFormatDb(subject string) string

Given a string, removes whitespace, hyphens and lowercases the string, making it ready for insertion or querying in the DB

Types

This section is empty.

Jump to

Keyboard shortcuts

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