Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeTime(id ULID) (int64, error)
- func EncodeRandom(length int, rng PRNG) (string, error)
- func EncodeTime(unix int64) (string, error)
- func FixULIDBase32(input string) string
- func FromUUID(uuid string) (string, error)
- func IncrementBase32(str string) (string, error)
- func IsValid(id string) bool
- type Factory
- type PRNG
- type ULID
- type UUID
Constants ¶
View Source
const B32_CHARACTERS = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"
View Source
const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ" // Crockford's Base32
View Source
const ENCODING_LEN = 32 // from ENCODING.length;
View Source
const MAX_ULID = "7ZZZZZZZZZZZZZZZZZZZZZZZZZ"
View Source
const MIN_ULID = "00000000000000000000000000"
View Source
const RANDOM_LEN = 16
View Source
const TIME_LEN = 10
View Source
const TIME_MAX int64 = 281474976710655 // from Math.pow(2, 48) - 1;
Variables ¶
View Source
var ErrBase32IncorrectEncoding = errors.New("B32_ENC_INVALID")
View Source
var ErrDecodeTimeInvalidCharacter = errors.New("DEC_TIME_CHAR")
View Source
var ErrDecodeTimeValueMalformed = errors.New("DEC_TIME_MALFORMED")
View Source
var ErrEncodeTimeNegative = errors.New("ENC_TIME_NEG")
View Source
var ErrEncodeTimeSizeExceeded = errors.New("ENC_TIME_SIZE_EXCEED")
View Source
var ErrEncodeTimeValueMalformed = errors.New("ENC_TIME_MALFORMED")
View Source
var ErrPRNGDetectFailure = errors.New("PRNG_DETECT")
View Source
var ErrULIDInvalid = errors.New("ULID_INVALID")
View Source
var ErrUUIDInvalid = errors.New("UUID_INVALID")
View Source
var ErrUnexpected = errors.New("UNEXPECTED")
View Source
var REGEX = regexp.MustCompile("^[0-7][0-9a-hjkmnp-tv-zA-HJKMNP-TV-Z]{25}$")
View Source
var UUID_REGEX = regexp.MustCompile("^[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$")
Functions ¶
func DecodeTime ¶
func EncodeTime ¶
func FixULIDBase32 ¶
func IncrementBase32 ¶
FIXME this is a direct translation of https://github.com/ulid/javascript/blob/11c2067821ee19e4dc787ca4e0125a025485edc6/source/crockford.ts#L62
Types ¶
type Factory ¶
func NewFactory ¶
Click to show internal directories.
Click to hide internal directories.