core

package
v0.0.0-...-07f0968 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Exit = os.Exit
)

Functions

func Do

func Do(f func(), r func(interface{}))

func Err

func Err(f string, args ...interface{}) error

func ExitIf

func ExitIf(condition bool, format string, args ...interface{})

func ExitOn

func ExitOn(i interface{})

func Go

func Go(f func(), r func(interface{}))

func MustGoGroup

func MustGoGroup(fs ...func())

func Now

func Now() time.Time

func NowMilli

func NowMilli() time.Time

func NowUnixMilli

func NowUnixMilli() int64

func NowUnixNano

func NowUnixNano() int64

func PanicIf

func PanicIf(condition bool, format string, args ...interface{})

func PanicIfZeroID

func PanicIfZeroID(id ID)

func PanicOn

func PanicOn(i interface{})

func Print

func Print(args ...interface{})

func Printf

func Printf(f string, args ...interface{})

func Println

func Println(args ...interface{})

func Recover

func Recover(r func(interface{}))

func Str

func Str(args ...interface{}) string

func StrContains

func StrContains(s, substr string) bool

func StrEllipsis

func StrEllipsis(s string, max uint) string

func StrHasPrefix

func StrHasPrefix(s, prefix string) bool

func StrHasSuffix

func StrHasSuffix(s, suffix string) bool

func StrJoin

func StrJoin(strs []string, sep string) string

func StrLen

func StrLen(s string) int

func StrLower

func StrLower(s string) string

func StrRepeat

func StrRepeat(s string, count int) string

func StrReplace

func StrReplace(s, old, new string, n int) string

func StrReplaceAll

func StrReplaceAll(s, old, new string) string

func StrSplit

func StrSplit(s string, sep string) []string

func StrTrim

func StrTrim(s, cutset string) string

func StrTrimWS

func StrTrimWS(s string) string

func StrUpper

func StrUpper(s string) string

func Strf

func Strf(f string, args ...interface{}) string

func Strln

func Strln(args ...interface{}) string

Types

type Bit

type Bit uint8

func (Bit) Bool

func (b Bit) Bool() bool

func (Bit) MarshalBinary

func (b Bit) MarshalBinary() ([]byte, error)

func (Bit) MarshalJSON

func (b Bit) MarshalJSON() ([]byte, error)

func (Bit) MarshalText

func (b Bit) MarshalText() ([]byte, error)

func (*Bit) UnmarshalBinary

func (b *Bit) UnmarshalBinary(d []byte) error

func (*Bit) UnmarshalJSON

func (b *Bit) UnmarshalJSON(d []byte) error

func (*Bit) UnmarshalText

func (b *Bit) UnmarshalText(d []byte) error

type Bits

type Bits []Bit

func (Bits) MarshalBinary

func (bs Bits) MarshalBinary() ([]byte, error)

func (Bits) MarshalText

func (bs Bits) MarshalText() ([]byte, error)

func (*Bits) UnmarshalBinary

func (bs *Bits) UnmarshalBinary(ds []byte) error

func (*Bits) UnmarshalText

func (bs *Bits) UnmarshalText(d []byte) error

type Error

type Error interface {
	error
	String() string
	Message() string
	StackTrace() string
	Value() interface{}
}

func GoGroup

func GoGroup(fs ...func()) Error

func ToError

func ToError(i interface{}) Error

type Errors

type Errors []Error

func (Errors) Error

func (es Errors) Error() string

func (Errors) String

func (es Errors) String() string

type ID

type ID ulid.ULID

func MustParseID

func MustParseID(id string) ID

func ParseID

func ParseID(id string) (ID, error)

func (ID) Compare

func (id ID) Compare(other ID) int

func (ID) Copy

func (id ID) Copy() ID

func (ID) Equal

func (id ID) Equal(other ID) bool

func (ID) IsZero

func (id ID) IsZero() bool

func (ID) MarshalBinary

func (id ID) MarshalBinary() ([]byte, error)

func (ID) MarshalBinaryTo

func (id ID) MarshalBinaryTo(dst []byte) error

func (ID) MarshalText

func (id ID) MarshalText() ([]byte, error)

func (ID) MarshalTextTo

func (id ID) MarshalTextTo(dst []byte) error

func (*ID) Scan

func (id *ID) Scan(src interface{}) error

func (ID) String

func (id ID) String() string

func (ID) Time

func (id ID) Time() time.Time

func (*ID) UnmarshalBinary

func (id *ID) UnmarshalBinary(data []byte) error

func (*ID) UnmarshalText

func (id *ID) UnmarshalText(data []byte) error

func (ID) Value

func (id ID) Value() (driver.Value, error)

type IDGen

type IDGen interface {
	New() (ID, error)
	MustNew() ID
}

func NewIDGen

func NewIDGen() IDGen

type IDGenPool

type IDGenPool interface {
	Get() IDGen
}

func NewIDGenPool

func NewIDGenPool(size int) IDGenPool

n.b. each IDGen allocates approx 5kb of memory so use a fixed pool to save on lots of big memory de/allocations

type IDs

type IDs []ID

func IDsMerge

func IDsMerge(idss ...IDs) IDs

func (*IDs) Scan

func (ids *IDs) Scan(src interface{}) error

useful for IDs columns or GROUP_CONCAT(id_col SEPARATOR ”)

func (IDs) StrJoin

func (ids IDs) StrJoin(sep string) string

func (IDs) ToIs

func (ids IDs) ToIs() []interface{}

func (IDs) Value

func (ids IDs) Value() (driver.Value, error)

type Key

type Key string

keys are user defined ids, max chars 50

func MustParseKey

func MustParseKey(s string) Key

func MustToKey

func MustToKey(s string) Key

func MustToKeyPtr

func MustToKeyPtr(s string) *Key

func ParseKey

func ParseKey(s string) (Key, error)

func ToKey

func ToKey(s string) (Key, error)

func ToKeyPtr

func ToKeyPtr(s string) (*Key, error)

func (Key) MarshalBinary

func (s Key) MarshalBinary() ([]byte, error)

func (Key) MarshalBinaryTo

func (s Key) MarshalBinaryTo(dst []byte) error

func (Key) MarshalText

func (s Key) MarshalText() ([]byte, error)

func (Key) MarshalTextTo

func (s Key) MarshalTextTo(dst []byte) error

func (*Key) Scan

func (s *Key) Scan(src interface{}) error

func (*Key) String

func (s *Key) String() string

func (*Key) UnmarshalBinary

func (s *Key) UnmarshalBinary(data []byte) error

func (*Key) UnmarshalText

func (s *Key) UnmarshalText(data []byte) error

func (Key) Value

func (s Key) Value() (driver.Value, error)

type Keys

type Keys []Key

func MustParseKeys

func MustParseKeys(ss []string) Keys

func MustToKeys

func MustToKeys(ss []string) Keys

func ParseKeys

func ParseKeys(ss []string) (Keys, error)

func ToKeys

func ToKeys(ss []string) (Keys, error)

func (*Keys) Scan

func (ks *Keys) Scan(src interface{}) error

useful for Keys columns or GROUP_CONCAT(key_col)

func (Keys) ToIs

func (s Keys) ToIs() []interface{}

func (Keys) Value

func (ks Keys) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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