Documentation ¶
Index ¶
- Variables
- func B2S(bts []byte) string
- func ByteToStr(bts []byte) string
- func CPUTicks() int64
- func CertTemplate() (*x509.Certificate, error)
- func CreateCert(template, parent *x509.Certificate, pub interface{}, parentPriv interface{}) (cert *x509.Certificate, certPEM []byte, err error)
- func Duration(t int64) time.Duration
- func FastRand() uint32
- func GenerateSelfSignedCerts(keyPath, certPath string)
- func GetCertificate(keyPath, certPath string) tls.Certificate
- func GetCountryCode(phone string) string
- func Int32ToStr(x int32) string
- func Int64ToStr(x int64) string
- func IntToStr(x int) string
- func MustSha256(in []byte) []byte
- func MustSha512(in, out []byte)
- func NanoTime() int64
- func NewPipeCommands(cmds ...*exec.Cmd) (*cmdPipe, error)
- func PromptCompleter(rootCmd *cobra.Command) func(d prompt.Document) []prompt.Suggest
- func PromptExecutor(rootCmd *cobra.Command) func(s string)
- func RandomDigit(n int) string
- func RandomID(n int) string
- func RandomInt(n int) (x int)
- func RandomInt64(n int64) (x int64)
- func RandomUint64(n uint64) (x uint64)
- func S2B(str string) []byte
- func SanitizePhone(phoneNumber string, defaultRegion string) string
- func SecureRandomInt63(n int64) (x int64)
- func SecureRandomUint64() (x uint64)
- func SetFlags(cmd *cobra.Command, opts ...FlagOption)
- func SetPersistentFlags(cmd *cobra.Command, opts ...FlagOption)
- func Sha256(in []byte) ([]byte, error)
- func Sha512(in, out []byte) error
- func SliceBytesDiff(a, b [][]byte, cb func([]byte))
- func SliceInt32Diff(a, b []int32, cb func(int32))
- func SliceInt64Diff(a, b []int64, cb func(int64))
- func SliceIntDiff(a, b []int, cb func(int))
- func SliceStringDiff(a, b []string, cb func(string))
- func SliceUint32Diff(a, b []uint32, cb func(uint32))
- func SliceUint64Diff(a, b []uint64, cb func(uint64))
- func SliceUintDiff(a, b []uint, cb func(uint))
- func StrToByte(str string) (b []byte)
- func StrToInt(s string) int
- func StrToInt32(s string) int32
- func StrToInt64(s string) int64
- func StrToUInt32(s string) uint32
- func StrToUInt64(s string) uint64
- func TimeUnix() int64
- func ToCamel(s string) string
- func ToDelimited(s string, delimiter uint8) string
- func ToKebab(s string) string
- func ToLowerCamel(s string) string
- func ToScreamingDelimited(s string, delimiter uint8, ignore uint8, screaming bool) string
- func ToScreamingKebab(s string) string
- func ToScreamingSnake(s string) string
- func ToSnake(s string) string
- func ToSnakeWithIgnore(s string, ignore uint8) string
- func TruncateString(str string, l int) string
- func Try(attempts int, waitTime time.Duration, f RetryableFunc) (err error)
- func TryFast(f RetryableFunc) error
- func TrySlow(f RetryableFunc) error
- func TrySuperFast(f RetryableFunc) error
- func UInt32ToStr(x uint32) string
- func UInt64ToStr(x uint64) string
- type FlagOption
- func RegisterBoolFlag(name string, value bool, usage string) FlagOption
- func RegisterDurationFlag(name string, value time.Duration, usage string) FlagOption
- func RegisterInt32Flag(name string, value int32, usage string) FlagOption
- func RegisterInt64Flag(name string, value int64, usage string) FlagOption
- func RegisterInt64SliceFlag(name string, value []int64, usage string) FlagOption
- func RegisterIntFlag(name string, value int, usage string) FlagOption
- func RegisterStringFlag(name, value, usage string) FlagOption
- func RegisterStringSliceFlag(name string, value []string, usage string) FlagOption
- func RegisterUInt64Flag(name string, value uint64, usage string) FlagOption
- type FlushEntry
- type FlusherFunc
- type FlusherPool
- type LinkedList
- func (ll *LinkedList) Append(data interface{})
- func (ll *LinkedList) Get(index int32) (n *Node)
- func (ll *LinkedList) Head() *Node
- func (ll *LinkedList) PickHeadData() interface{}
- func (ll *LinkedList) PickTailData() interface{}
- func (ll *LinkedList) Prepend(data interface{})
- func (ll *LinkedList) RemoveAt(index int32)
- func (ll *LinkedList) Reset()
- func (ll *LinkedList) Size() int32
- func (ll *LinkedList) String() string
- func (ll *LinkedList) Tail() *Node
- type Node
- type RetryableFunc
- type SpinLock
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoCmds = errors.New("pipe: there were no commands provided")
)
var (
RegExPhone *regexp.Regexp
)
Functions ¶
func ByteToStr ¶
ByteToStr converts byte slice to a string without memory allocation. Note it may break if string and/or slice header will change in the future go versions.
func CPUTicks ¶ added in v0.0.35
func CPUTicks() int64
CPUTicks is a faster alternative to NanoTime to measure time duration.
func CertTemplate ¶
func CertTemplate() (*x509.Certificate, error)
helper function to create a cert template with a serial number and other required fields
func CreateCert ¶
func CreateCert(template, parent *x509.Certificate, pub interface{}, parentPriv interface{}) (cert *x509.Certificate, certPEM []byte, err error)
func FastRand ¶ added in v0.0.35
func FastRand() uint32
FastRand is a fast thread local random function.
func GenerateSelfSignedCerts ¶
func GenerateSelfSignedCerts(keyPath, certPath string)
func GetCertificate ¶
func GetCertificate(keyPath, certPath string) tls.Certificate
func GetCountryCode ¶
func Int32ToStr ¶
func Int64ToStr ¶
func MustSha256 ¶
func MustSha512 ¶
func MustSha512(in, out []byte)
func NanoTime ¶ added in v0.0.35
func NanoTime() int64
NanoTime returns the current time in nanoseconds from a monotonic clock.
func NewPipeCommands ¶
func PromptCompleter ¶ added in v0.3.3
PromptCompleter returns a completer function used by prompt package. This function is useful to create an interactive shell based on the rootCmd as the root commands.
func PromptExecutor ¶ added in v0.3.3
PromptExecutor returns an executor function used by prompt package. This function is useful to create an interactive shell based on the rootCmd as the root commands.
func RandomDigit ¶
RandomDigit generates a pseudo-random string with length 'n' which characters are only digits (0-9)
func RandomID ¶
RandomID generates a pseudo-random string with length 'n' which characters are alphanumerics.
func RandomInt64 ¶
RandomInt64 produces a pseudo-random number, if n == 0 there will be no limit otherwise the output will be smaller than n
func RandomUint64 ¶
RandUint64 produces a pseudo-random unsigned number
func SanitizePhone ¶
func SecureRandomInt63 ¶
func SecureRandomUint64 ¶
func SecureRandomUint64() (x uint64)
func SetFlags ¶ added in v0.0.43
func SetFlags(cmd *cobra.Command, opts ...FlagOption)
SetFlags applies 'opts' on 'cmd' flags in order.
func SetPersistentFlags ¶ added in v0.0.43
func SetPersistentFlags(cmd *cobra.Command, opts ...FlagOption)
SetPersistentFlags applies 'opts' on 'cmd' persistent flags.
func SliceBytesDiff ¶ added in v0.3.9
SliceBytesDiff returns a - b and cb will be called on each found difference.
func SliceInt32Diff ¶ added in v0.3.9
SliceInt32Diff returns a - b and cb will be called on each found difference.
func SliceInt64Diff ¶ added in v0.3.9
SliceInt64Diff returns a - b and cb will be called on each found difference.
func SliceIntDiff ¶ added in v0.3.9
SliceIntDiff returns a - b and cb will be called on each found difference.
func SliceStringDiff ¶ added in v0.3.9
SliceInt64Diff returns a - b and cb will be called on each found difference.
func SliceUint32Diff ¶ added in v0.3.9
SliceUint32Diff returns a - b and cb will be called on each found difference.
func SliceUint64Diff ¶ added in v0.3.9
SliceUint64Diff returns a - b and cb will be called on each found difference.
func SliceUintDiff ¶ added in v0.3.9
SliceUintDiff returns a - b and cb will be called on each found difference.
func StrToByte ¶
StrToByte converts string to a byte slice without memory allocation. Note it may break if string and/or slice header will change in the future go versions.
func StrToInt32 ¶
func StrToInt64 ¶
func StrToUInt32 ¶
func StrToUInt64 ¶
func ToDelimited ¶
ToDelimited converts a string to delimited.snake.case (in this case `delimiter = '.'`)
func ToLowerCamel ¶
ToLowerCamel converts a string to lowerCamelCase
func ToScreamingDelimited ¶
ToScreamingDelimited converts a string to SCREAMING.DELIMITED.SNAKE.CASE (in this case `delimiter = '.'; screaming = true`) or delimited.snake.case (in this case `delimiter = '.'; screaming = false`)
func ToScreamingKebab ¶
ToScreamingKebab converts a string to SCREAMING-KEBAB-CASE
func ToScreamingSnake ¶
ToScreamingSnake converts a string to SCREAMING_SNAKE_CASE
func ToSnakeWithIgnore ¶
func TruncateString ¶ added in v0.6.26
TruncateString cuts the over sized string str upto l.
func TryFast ¶ added in v0.6.26
func TryFast(f RetryableFunc) error
func TrySlow ¶ added in v0.6.26
func TrySlow(f RetryableFunc) error
func TrySuperFast ¶ added in v0.6.26
func TrySuperFast(f RetryableFunc) error
func UInt32ToStr ¶
func UInt64ToStr ¶
Types ¶
type FlagOption ¶ added in v0.0.43
FlagOption applies some predefined configurations on a FlagSet.
func RegisterBoolFlag ¶ added in v0.0.43
func RegisterBoolFlag(name string, value bool, usage string) FlagOption
func RegisterDurationFlag ¶ added in v0.0.43
func RegisterDurationFlag(name string, value time.Duration, usage string) FlagOption
func RegisterInt32Flag ¶ added in v0.0.43
func RegisterInt32Flag(name string, value int32, usage string) FlagOption
func RegisterInt64Flag ¶ added in v0.0.43
func RegisterInt64Flag(name string, value int64, usage string) FlagOption
func RegisterInt64SliceFlag ¶ added in v0.0.43
func RegisterInt64SliceFlag(name string, value []int64, usage string) FlagOption
func RegisterIntFlag ¶ added in v0.0.43
func RegisterIntFlag(name string, value int, usage string) FlagOption
func RegisterStringFlag ¶ added in v0.0.43
func RegisterStringFlag(name, value, usage string) FlagOption
func RegisterStringSliceFlag ¶ added in v0.0.43
func RegisterStringSliceFlag(name string, value []string, usage string) FlagOption
func RegisterUInt64Flag ¶ added in v0.0.43
func RegisterUInt64Flag(name string, value uint64, usage string) FlagOption
type FlushEntry ¶ added in v0.1.4
type FlushEntry interface { Value() interface{} // contains filtered or unexported methods }
func NewEntry ¶ added in v0.1.4
func NewEntry(v interface{}) FlushEntry
type FlusherFunc ¶ added in v0.1.4
type FlusherFunc func(targetID string, entries []FlushEntry)
type FlusherPool ¶ added in v0.3.2
type FlusherPool struct {
// contains filtered or unexported fields
}
func NewFlusherPool ¶ added in v0.1.4
func NewFlusherPool(maxWorkers, batchSize int32, f FlusherFunc) *FlusherPool
NewFlusherPool creates a pool of flusher funcs. By calling Enter or EnterAndWait you add the item into the flusher which identified by 'targetID'.
func (*FlusherPool) Enter ¶ added in v0.3.2
func (fp *FlusherPool) Enter(targetID string, entry FlushEntry)
func (*FlusherPool) EnterAndWait ¶ added in v0.3.2
func (fp *FlusherPool) EnterAndWait(targetID string, entry FlushEntry)
type LinkedList ¶
type LinkedList struct {
// contains filtered or unexported fields
}
func NewLinkedList ¶
func NewLinkedList() *LinkedList
func (*LinkedList) Append ¶
func (ll *LinkedList) Append(data interface{})
func (*LinkedList) Get ¶
func (ll *LinkedList) Get(index int32) (n *Node)
func (*LinkedList) Head ¶
func (ll *LinkedList) Head() *Node
func (*LinkedList) PickHeadData ¶
func (ll *LinkedList) PickHeadData() interface{}
func (*LinkedList) PickTailData ¶
func (ll *LinkedList) PickTailData() interface{}
func (*LinkedList) Prepend ¶
func (ll *LinkedList) Prepend(data interface{})
func (*LinkedList) RemoveAt ¶
func (ll *LinkedList) RemoveAt(index int32)
func (*LinkedList) Reset ¶
func (ll *LinkedList) Reset()
func (*LinkedList) Size ¶
func (ll *LinkedList) Size() int32
func (*LinkedList) String ¶
func (ll *LinkedList) String() string
func (*LinkedList) Tail ¶
func (ll *LinkedList) Tail() *Node
type RetryableFunc ¶
type RetryableFunc func() error
type SpinLock ¶ added in v0.1.4
type SpinLock struct {
// contains filtered or unexported fields
}
SpinLock is a spinlock implementation.
A SpinLock must not be copied after first use. This SpinLock intended to be used to synchronize exceptionally short lived operations.