utils

package
v0.0.0-...-4e1d4fc Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ZeroTime0 = "0000-00-00 00:00:00"
	ZeroTime1 = "0001-01-01 00:00:00"
)
View Source
const (
	DEFAULT_ALPHABET = "23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
)

Variables

View Source
var (
	// NIL is defined in RFC 4122 section 4.1.7.
	// The nil UUID is special form of UUID that is specified to have all 128 bits set to zero.
	NIL = &UUID{
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	}
	// NameSpaceDNS assume name to be a fully-qualified domain name.
	// Declared in RFC 4122 Appendix C.
	NameSpaceDNS = &UUID{
		0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1,
		0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
	}
	// NameSpaceURL assume name to be a URL.
	// Declared in RFC 4122 Appendix C.
	NameSpaceURL = &UUID{
		0x6b, 0xa7, 0xb8, 0x11, 0x9d, 0xad, 0x11, 0xd1,
		0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
	}
	// NameSpaceOID assume name to be an ISO OID.
	// Declared in RFC 4122 Appendix C.
	NameSpaceOID = &UUID{
		0x6b, 0xa7, 0xb8, 0x12, 0x9d, 0xad, 0x11, 0xd1,
		0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
	}
	// NameSpaceX500 assume name to be a X.500 DN (in DER or a text output format).
	// Declared in RFC 4122 Appendix C.
	NameSpaceX500 = &UUID{
		0x6b, 0xa7, 0xb8, 0x14, 0x9d, 0xad, 0x11, 0xd1,
		0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
	}
)
View Source
var (
	NamespaceDNS, _  = FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
	NamespaceURL, _  = FromString("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
	NamespaceOID, _  = FromString("6ba7b812-9dad-11d1-80b4-00c04fd430c8")
	NamespaceX500, _ = FromString("6ba7b814-9dad-11d1-80b4-00c04fd430c8")
)

Functions

func IndexName

func IndexName(tableName, idxName string) string

func IndexNoCase

func IndexNoCase(s, sep string) int

func IsArrayZero

func IsArrayZero(v reflect.Value) bool

func IsStructZero

func IsStructZero(v reflect.Value) bool

func IsSubQuery

func IsSubQuery(tbName string) bool

func IsTimeZero

func IsTimeZero(t time.Time) bool

func IsValueZero

func IsValueZero(v reflect.Value) bool

func IsZero

func IsZero(k interface{}) bool

IsZero returns false if k is nil or has a zero value

func ReflectValue

func ReflectValue(bean interface{}) reflect.Value

func SliceEq

func SliceEq(left, right []string) bool

SliceEq return true if two slice have the same elements even if different sort.

func SplitNNoCase

func SplitNNoCase(s, sep string, n int) []string

func SplitNoCase

func SplitNoCase(s, sep string) []string

Types

type ShortUUID

type ShortUUID struct {
	// contains filtered or unexported fields
}

func NewShortUUID

func NewShortUUID() *ShortUUID

func NewShortUUIDWithAlphabet

func NewShortUUIDWithAlphabet(alphabet string) *ShortUUID

func (*ShortUUID) Decode

func (s *ShortUUID) Decode(input string) (UUID, error)

func (*ShortUUID) Encode

func (s *ShortUUID) Encode(uuid *UUID) string

Encodes a UUID into a string (LSB first) according to the alphabet If leftmost (MSB) bits 0, string might be shorter

func (*ShortUUID) SetAlphabet

func (s *ShortUUID) SetAlphabet(alphabet string)

func (ShortUUID) String

func (s ShortUUID) String() string

func (*ShortUUID) UUID

func (s *ShortUUID) UUID(name string) string

type StringSet

type StringSet struct {
	// contains filtered or unexported fields
}

func NewStringSet

func NewStringSet() *StringSet

func (*StringSet) Add

func (set *StringSet) Add(i string) bool

func (*StringSet) Contains

func (set *StringSet) Contains(i string) bool

func (*StringSet) Index

func (set *StringSet) Index(c string) int

func (*StringSet) ItemByIndex

func (set *StringSet) ItemByIndex(idx int) string

func (*StringSet) Len

func (set *StringSet) Len() int

func (*StringSet) Remove

func (set *StringSet) Remove(i string)

func (*StringSet) Sort

func (set *StringSet) Sort()

func (*StringSet) String

func (set *StringSet) String() string

type UUID

type UUID [16]byte

The UUID represents Universally Unique IDentifier (which is 128 bit long).

func FromString

func FromString(input string) (u UUID, err error)

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

func NewNamespaceUUID

func NewNamespaceUUID(namespace string) *UUID

NewNamespaceUUID creates a namespace UUID by using the namespace name in the NIL name space. This is a different approach as the 4 "standard" namespace UUIDs which are timebased UUIDs (V1).

func NewV1

func NewV1() *UUID

NewV1 creates a new UUID with variant 1 as described in RFC 4122. Variant 1 is based on hosts MAC address and actual timestamp (as count of 100-nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian reform to the Christian calendar).

func NewV3

func NewV3(namespace *UUID, name []byte) *UUID

NewV3 creates a new UUID with variant 3 as described in RFC 4122. Variant 3 based namespace-uuid and name and MD-5 hash calculation.

func NewV4

func NewV4() *UUID

NewV4 creates a new UUID with variant 4 as described in RFC 4122. Variant 4 based on pure random bytes.

func NewV5

func NewV5(namespaceUUID *UUID, name []byte) *UUID

NewV5 creates a new UUID with variant 5 as described in RFC 4122. Variant 5 based namespace-uuid and name and SHA-1 hash calculation.

func (*UUID) String

func (u *UUID) String() string

String returns the human readable form of the UUID.

func (*UUID) UnmarshalText

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

func (*UUID) Version

func (u *UUID) Version() int

Version of the UUID represents a kind of subtype specifier.

func (*UUID) WithoutDashString

func (u *UUID) WithoutDashString() string

type Zeroable

type Zeroable interface {
	IsZero() bool
}

Jump to

Keyboard shortcuts

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