gg_utils

package
v0.2.84 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: BSD-3-Clause Imports: 52 Imported by: 21

Documentation

Index

Constants

View Source
const (
	ChunkSizeSmall  = int64(256 * 1024)      // 256k
	ChunkSizeMedium = int64(512 * 1024)      // 512k
	ChunkSizeLarge  = int64(1 * 1024 * 1024) // 1Mb
)
View Source
const (
	DatePattern           = `` /* 461-byte string literal not displayed */
	TimePattern           = `(?i)\d{1,2}:\d{2} ?(?:[ap]\.?m\.?)?|\d[ap]\.?m\.?`
	PhonePattern          = `` /* 133-byte string literal not displayed */
	PhonesWithExtsPattern = `` /* 273-byte string literal not displayed */
	LinkPattern           = `` /* 176-byte string literal not displayed */
	LinkPatternStrict     = `(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?`
	EmailPattern          = `(?i)([A-Za-z0-9!#$%&'*+\/=?^_{|.}~-]+@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)`
	IPv4Pattern           = `(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)`
	IPv6Pattern           = `` /* 1224-byte string literal not displayed */
	IPPattern             = IPv4Pattern + `|` + IPv6Pattern
	NotKnownPortPattern   = `6[0-5]{2}[0-3][0-5]|[1-5][\d]{4}|[2-9][\d]{3}|1[1-9][\d]{2}|10[3-9][\d]|102[4-9]`
	//PricePattern          = `[$]\s?[+-]?[0-9]{1,3}(?:(?:,?[0-9]{3}))*(?:\.[0-9]{1,2})?`
	PricePattern          = `[$€]?\s?[+-]?[0-9]{1,3}(?:(?:(,|\.)?[0-9]{3}))*(?:(\.|,)[0-9]{1,3})?\s?[$€]?`
	HexColorPattern       = `(?:#?([0-9a-fA-F]{6}|[0-9a-fA-F]{3}))`
	CreditCardPattern     = `(?:(?:(?:\d{4}[- ]?){3}\d{4}|\d{15,16}))`
	VISACreditCardPattern = `4\d{3}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}`
	MCCreditCardPattern   = `5[1-5]\d{2}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}`
	BtcAddressPattern     = `[13][a-km-zA-HJ-NP-Z1-9]{25,34}`
	StreetAddressPattern  = `` /* 149-byte string literal not displayed */
	ZipCodePattern        = `\b\d{5}(?:[-\s]\d{4})?\b`
	PoBoxPattern          = `(?i)P\.? ?O\.? Box \d+`
	SSNPattern            = `(?:\d{3}-\d{2}-\d{4})`
	MD5HexPattern         = `[0-9a-fA-F]{32}`
	SHA1HexPattern        = `[0-9a-fA-F]{40}`
	SHA256HexPattern      = `[0-9a-fA-F]{64}`
	GUIDPattern           = `[0-9a-fA-F]{8}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{12}`
	ISBN13Pattern         = `(?:[\d]-?){12}[\dxX]`
	ISBN10Pattern         = `(?:[\d]-?){9}[\dxX]`
	MACAddressPattern     = `(([a-fA-F0-9]{2}[:-]){5}([a-fA-F0-9]{2}))`
	IBANPattern           = `[A-Z]{2}\d{2}[A-Z0-9]{4}\d{7}([A-Z\d]?){0,16}`
	GitRepoPattern        = `((git|ssh|http(s)?)|(git@[\w\.]+))(:(\/\/)?)([\w\.@\:/\-~]+)(\.git)(\/)?`
	NumbersPattern        = `[-+]?(?:[0-9]+(\.|,))*[0-9]+(?:\.[0-9]+)?`
	BracesPattern         = `\{{(.*?)\}}` // `{{\s*[\w\.]+\s*}}`
)

Regular expression patterns

View Source
const DEF_TEMP = gg_.DEF_TEMP
View Source
const DEF_WORKSPACE = "_workspace"
View Source
const (
	// DefaultMaxConcurrent is max number of concurrent routines
	DefaultMaxConcurrent = 100
)
View Source
const OS_PATH_SEPARATOR = gg_.OS_PATH_SEPARATOR

Variables

View Source
var (
	Kb = uint64(1024)
	Mb = Kb * 1024
	Gb = Mb * 1024
	Tb = Gb * 1024
	Pb = Tb * 1024
	Eb = Pb * 1024
)
View Source
var (
	DatePatterns = []string{
		"yyyyMMdd",
		"yyyyMMdd HH:mm",
		"yyyyMMdd HH:mm:ss",
		"yyyyMMdd HH:mm ss",
		"yyyyMMdd HH mm",
		"yyyyMMdd HH mm ss",
		"HH:mm",
		"HH:mm:ss",
		"HH:mm ss",
		"HH mm",
		"HH mm ss",
	}

	LocalePatterns = map[string][]string{
		"*":  {"MM dd yyyy", "MM dd yyyy HH:mm", "MM dd yyyy HH:mm:ss"},
		"it": {"dd MM yyyy", "dd MM yyyy HH:mm", "dd MM yyyy HH:mm:ss"},
		"fr": {"dd MM yyyy", "dd MM yyyy HH:mm", "dd MM yyyy HH:mm:ss"},
	}
)
View Source
var (
	DateRegex           = regexp.MustCompile(DatePattern)
	TimeRegex           = regexp.MustCompile(TimePattern)
	PhoneRegex          = regexp.MustCompile(PhonePattern)
	PhonesWithExtsRegex = regexp.MustCompile(PhonesWithExtsPattern)
	LinkRegex           = regexp.MustCompile(LinkPattern)
	UrlRegex            = regexp.MustCompile(LinkPatternStrict)
	EmailRegex          = regexp.MustCompile(EmailPattern)
	IPv4Regex           = regexp.MustCompile(IPv4Pattern)
	IPv6Regex           = regexp.MustCompile(IPv6Pattern)
	IPRegex             = regexp.MustCompile(IPPattern)
	NotKnownPortRegex   = regexp.MustCompile(NotKnownPortPattern)
	PriceRegex          = regexp.MustCompile(PricePattern)
	HexColorRegex       = regexp.MustCompile(HexColorPattern)
	CreditCardRegex     = regexp.MustCompile(CreditCardPattern)
	BtcAddressRegex     = regexp.MustCompile(BtcAddressPattern)
	StreetAddressRegex  = regexp.MustCompile(StreetAddressPattern)
	ZipCodeRegex        = regexp.MustCompile(ZipCodePattern)
	PoBoxRegex          = regexp.MustCompile(PoBoxPattern)
	SSNRegex            = regexp.MustCompile(SSNPattern)
	MD5HexRegex         = regexp.MustCompile(MD5HexPattern)
	SHA1HexRegex        = regexp.MustCompile(SHA1HexPattern)
	SHA256HexRegex      = regexp.MustCompile(SHA256HexPattern)
	GUIDRegex           = regexp.MustCompile(GUIDPattern)
	ISBN13Regex         = regexp.MustCompile(ISBN13Pattern)
	ISBN10Regex         = regexp.MustCompile(ISBN10Pattern)
	VISACreditCardRegex = regexp.MustCompile(VISACreditCardPattern)
	MCCreditCardRegex   = regexp.MustCompile(MCCreditCardPattern)
	MACAddressRegex     = regexp.MustCompile(MACAddressPattern)
	IBANRegex           = regexp.MustCompile(IBANPattern)
	GitRepoRegex        = regexp.MustCompile(GitRepoPattern)
	NumbersRegex        = regexp.MustCompile(NumbersPattern)
	BracesRegex         = regexp.MustCompile(BracesPattern)
)

Compiled regular expressions

View Source
var (
	// ErrAmbiguousMMDD for date formats such as 04/02/2014 the mm/dd vs dd/mm are
	// ambiguous, so it is an error for strict parse rules.
	ErrAmbiguousMMDD = fmt.Errorf("This date has ambiguous mm/dd vs dd/mm type format")
)
View Source
var (
	SQLBlackList = []string{"alter", "ALTER", "EXEC", "exec", "EXECUTE", "execute", "create", "CREATE",
		"delete", "DELETE", "DROP", "drop", "INSERT", "insert", "UPDATE", "update", "UNION", "union",
		"--", "\"", "'",
	}
)

Functions

This section is empty.

Types

type ArraysHelper

type ArraysHelper struct {
}
var Arrays *ArraysHelper

func (*ArraysHelper) AppendUnique

func (instance *ArraysHelper) AppendUnique(target interface{}, source interface{}) interface{}

func (*ArraysHelper) AppendUniqueFunc

func (instance *ArraysHelper) AppendUniqueFunc(target interface{}, source interface{}, callback func(t interface{}, s interface{}) bool) interface{}

func (*ArraysHelper) Contains

func (instance *ArraysHelper) Contains(item interface{}, array interface{}) bool

func (*ArraysHelper) ContainsAll

func (instance *ArraysHelper) ContainsAll(items []interface{}, array interface{}) bool

func (*ArraysHelper) ContainsAny

func (instance *ArraysHelper) ContainsAny(items []interface{}, array interface{}) bool

func (*ArraysHelper) Copy

func (instance *ArraysHelper) Copy(array interface{}) interface{}

Copy a slice and return new slice with same items

func (*ArraysHelper) Count

func (instance *ArraysHelper) Count(item interface{}, array interface{}) int

func (*ArraysHelper) Filter

func (instance *ArraysHelper) Filter(array interface{}, callback func(item interface{}) bool) interface{}

func (*ArraysHelper) ForEach

func (instance *ArraysHelper) ForEach(array interface{}, callback func(item interface{}) bool)

func (*ArraysHelper) GetAt

func (instance *ArraysHelper) GetAt(array interface{}, index int, defValue interface{}) interface{}

func (*ArraysHelper) GetLast

func (instance *ArraysHelper) GetLast(array interface{}, defValue interface{}) interface{}

func (*ArraysHelper) Group

func (instance *ArraysHelper) Group(groupSize int, array interface{}) interface{}

Group a slice in batch. Returns a slice of slice. usage: response := Group([]int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) fmt.Println(response) // [[0 1 2] [3 4 5] [6 7 8] [9]]

func (*ArraysHelper) IndexOf

func (instance *ArraysHelper) IndexOf(item interface{}, array interface{}) int

func (*ArraysHelper) IndexOfFunc

func (instance *ArraysHelper) IndexOfFunc(array interface{}, callback func(item interface{}) bool) int

func (*ArraysHelper) IndexOfOne

func (instance *ArraysHelper) IndexOfOne(items []interface{}, array interface{}) int

func (*ArraysHelper) IsArray added in v0.2.76

func (instance *ArraysHelper) IsArray(array interface{}) bool

func (*ArraysHelper) LastIndexOf

func (instance *ArraysHelper) LastIndexOf(item interface{}, array interface{}) int

func (*ArraysHelper) Map

func (instance *ArraysHelper) Map(array interface{}, callback func(item interface{}) interface{}) interface{}

func (*ArraysHelper) Remove

func (instance *ArraysHelper) Remove(item interface{}, array interface{}) interface{}

func (*ArraysHelper) RemoveIndex

func (instance *ArraysHelper) RemoveIndex(idx int, array interface{}) interface{}

func (*ArraysHelper) Replace

func (instance *ArraysHelper) Replace(source interface{}, target interface{}, array interface{}, n int, shrink bool) interface{}

func (*ArraysHelper) ReplaceAll

func (instance *ArraysHelper) ReplaceAll(source, target interface{}, array interface{}) interface{}

func (*ArraysHelper) Reverse

func (instance *ArraysHelper) Reverse(array interface{})

func (*ArraysHelper) Shuffle

func (instance *ArraysHelper) Shuffle(array interface{})

func (*ArraysHelper) Sort

func (instance *ArraysHelper) Sort(array interface{})

func (*ArraysHelper) SortDesc

func (instance *ArraysHelper) SortDesc(array interface{})

func (*ArraysHelper) Sub

func (instance *ArraysHelper) Sub(array interface{}, start, end int) interface{}

type AsyncContext

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

func NewAsyncContext

func NewAsyncContext() *AsyncContext

func (*AsyncContext) Cancel

func (instance *AsyncContext) Cancel()

func (*AsyncContext) Done

func (instance *AsyncContext) Done() <-chan struct{}

func (*AsyncContext) Err

func (instance *AsyncContext) Err() error

func (*AsyncContext) IsCancelled

func (instance *AsyncContext) IsCancelled() bool

type AsyncHelper

type AsyncHelper struct {
}
var Async *AsyncHelper

func (*AsyncHelper) NewAsyncTask

func (instance *AsyncHelper) NewAsyncTask() *AsyncTask

func (*AsyncHelper) NewAsyncTimedTask

func (instance *AsyncHelper) NewAsyncTimedTask(timeout time.Duration, handler func()) *AsyncTask

func (*AsyncHelper) NewConcurrentPool

func (instance *AsyncHelper) NewConcurrentPool(limit int) *ConcurrentPool

type AsyncTask

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

func (*AsyncTask) Close

func (instance *AsyncTask) Close()

func (*AsyncTask) ElapsedMs

func (instance *AsyncTask) ElapsedMs() int

func (*AsyncTask) Error

func (instance *AsyncTask) Error() error

func (*AsyncTask) OnError

func (instance *AsyncTask) OnError(callback func(err error)) *AsyncTask

func (*AsyncTask) OnFinish

func (instance *AsyncTask) OnFinish(callback func(response interface{}, err error)) *AsyncTask

func (*AsyncTask) OnSuccess

func (instance *AsyncTask) OnSuccess(callback func(response interface{})) *AsyncTask

func (*AsyncTask) OnTimeout

func (instance *AsyncTask) OnTimeout(callback func()) *AsyncTask

func (*AsyncTask) Response

func (instance *AsyncTask) Response() interface{}

func (*AsyncTask) ResponseBool

func (instance *AsyncTask) ResponseBool() bool

func (*AsyncTask) ResponseFloat32

func (instance *AsyncTask) ResponseFloat32() float32

func (*AsyncTask) ResponseFloat64

func (instance *AsyncTask) ResponseFloat64() float64

func (*AsyncTask) ResponseInt

func (instance *AsyncTask) ResponseInt() int

func (*AsyncTask) ResponseInt32

func (instance *AsyncTask) ResponseInt32() int32

func (*AsyncTask) ResponseInt64

func (instance *AsyncTask) ResponseInt64() int64

func (*AsyncTask) ResponseInt8

func (instance *AsyncTask) ResponseInt8() int8

func (*AsyncTask) ResponseString

func (instance *AsyncTask) ResponseString() string

func (*AsyncTask) Run

func (instance *AsyncTask) Run(f AsyncTaskGoRoutine, args ...interface{}) *AsyncTask

func (*AsyncTask) RunSync

func (instance *AsyncTask) RunSync(f AsyncTaskGoRoutine, args ...interface{}) (elapsed int, response interface{}, err error)

func (*AsyncTask) SetTimeout

func (instance *AsyncTask) SetTimeout(timeout time.Duration) *AsyncTask

func (*AsyncTask) Wait

func (instance *AsyncTask) Wait() (elapsed int, response interface{}, err error)

type AsyncTaskGoRoutine

type AsyncTaskGoRoutine func(ctx *AsyncContext, args ...interface{}) (interface{}, error)

type BOMHelper

type BOMHelper struct {
}
var BOM *BOMHelper

func (*BOMHelper) CleanBom

func (instance *BOMHelper) CleanBom(b []byte) []byte

CleanBom returns b with the 3 byte BOM stripped off the front if it is present. If the BOM is not present, then b is returned.

func (*BOMHelper) NewReaderWithoutBom

func (instance *BOMHelper) NewReaderWithoutBom(r io.Reader) (io.Reader, error)

NewReaderWithoutBom returns an io.Reader that will skip over initial UTF-8 byte order marks.

type CodingHelper

type CodingHelper struct {
}
var Coding *CodingHelper

func (*CodingHelper) BytesToPrivateKey

func (instance *CodingHelper) BytesToPrivateKey(priv []byte) (*rsa.PrivateKey, error)

BytesToPrivateKey bytes to private key

func (*CodingHelper) BytesToPublicKey

func (instance *CodingHelper) BytesToPublicKey(pub []byte) (*rsa.PublicKey, error)

BytesToPublicKey bytes to public key

func (*CodingHelper) DecodeBase64

func (instance *CodingHelper) DecodeBase64(data string) ([]byte, error)

func (*CodingHelper) DecryptBytesAES

func (instance *CodingHelper) DecryptBytesAES(data []byte, key []byte) ([]byte, error)

func (*CodingHelper) DecryptFileAES

func (instance *CodingHelper) DecryptFileAES(fileName string, key []byte, optOutFileName string) ([]byte, error)

func (*CodingHelper) DecryptTextAES

func (instance *CodingHelper) DecryptTextAES(text string, key []byte) ([]byte, error)

func (*CodingHelper) DecryptTextWithPrefix

func (instance *CodingHelper) DecryptTextWithPrefix(text string, key []byte) (string, error)

func (*CodingHelper) DecryptWithPrivateKey

func (instance *CodingHelper) DecryptWithPrivateKey(ciphertext []byte, priv *rsa.PrivateKey) ([]byte, error)

DecryptWithPrivateKey decrypts data with private key

func (*CodingHelper) EncodeBase64

func (instance *CodingHelper) EncodeBase64(data []byte) string

func (*CodingHelper) EncryptBytesAES

func (instance *CodingHelper) EncryptBytesAES(data []byte, key []byte) ([]byte, error)

func (*CodingHelper) EncryptFileAES

func (instance *CodingHelper) EncryptFileAES(fileName string, key []byte, optOutFileName string) ([]byte, error)

func (*CodingHelper) EncryptTextAES

func (instance *CodingHelper) EncryptTextAES(text string, key []byte) ([]byte, error)

func (*CodingHelper) EncryptTextWithPrefix

func (instance *CodingHelper) EncryptTextWithPrefix(text string, key []byte) (string, error)

EncryptTextWithPrefix Encrypt using AES with a 32 byte key and adding a prefix to avoid multiple encryption Encrypted code is recognizable by the prefix. Useful for password encryption

func (*CodingHelper) EncryptWithPublicKey

func (instance *CodingHelper) EncryptWithPublicKey(msg []byte, pub *rsa.PublicKey) ([]byte, error)

EncryptWithPublicKey encrypts data with public key

func (*CodingHelper) GenerateKeyPair

func (instance *CodingHelper) GenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)

GenerateKeyPair generates a new an RSA keypair of the given bit size using the random source random (for example, crypto/rand.Reader).

func (*CodingHelper) GenerateSessionKey

func (instance *CodingHelper) GenerateSessionKey() [32]byte

func (*CodingHelper) Hash

func (instance *CodingHelper) Hash(h func() hash.Hash, secret []byte, message []byte) []byte

func (*CodingHelper) HashSha256

func (instance *CodingHelper) HashSha256(secret []byte, message []byte) []byte

func (*CodingHelper) HashSha512

func (instance *CodingHelper) HashSha512(secret []byte, message []byte) []byte

func (*CodingHelper) HtmlDecode

func (instance *CodingHelper) HtmlDecode(text string) (response string)

func (*CodingHelper) HtmlEncode

func (instance *CodingHelper) HtmlEncode(text string) (response string)

func (*CodingHelper) HtmlEncodeAll

func (instance *CodingHelper) HtmlEncodeAll(text string) (response string)

HtmlEncodeAll Convert every char in UTF-8 escaped HTML string i.e. "Ciao" become "&#67;&#105;&#97;&#111;"

func (*CodingHelper) MD5

func (instance *CodingHelper) MD5(text string) string

func (*CodingHelper) PrivateKeyToBytes

func (instance *CodingHelper) PrivateKeyToBytes(priv *rsa.PrivateKey) []byte

PrivateKeyToBytes convert private key to bytes

func (*CodingHelper) PublicKeyToBytes

func (instance *CodingHelper) PublicKeyToBytes(pub *rsa.PublicKey) ([]byte, error)

PublicKeyToBytes convert public key to bytes

func (*CodingHelper) SHA1

func (instance *CodingHelper) SHA1(text string) string

func (*CodingHelper) SHA256

func (instance *CodingHelper) SHA256(data []byte) string

func (*CodingHelper) SHA256FromFile

func (instance *CodingHelper) SHA256FromFile(filename string) (string, error)

func (*CodingHelper) SHA256FromText

func (instance *CodingHelper) SHA256FromText(text string) string

func (*CodingHelper) SHA512

func (instance *CodingHelper) SHA512(text string) string

func (*CodingHelper) UnwrapBase64

func (instance *CodingHelper) UnwrapBase64(value string) string

func (*CodingHelper) UrlDecode

func (instance *CodingHelper) UrlDecode(text string) string

func (*CodingHelper) UrlEncode

func (instance *CodingHelper) UrlEncode(text string) string

func (*CodingHelper) UrlEncodeAll

func (instance *CodingHelper) UrlEncodeAll(text string) (response string)

UrlEncodeAll Convert every char in escaped query string i.e. "Ciao" become "%43%69%61%6F"

func (*CodingHelper) WrapBase64

func (instance *CodingHelper) WrapBase64(value string) string

type CompareHelper

type CompareHelper struct {
}
var Compare *CompareHelper

func (*CompareHelper) Compare

func (instance *CompareHelper) Compare(item1, item2 interface{}) int

func (*CompareHelper) Equals

func (instance *CompareHelper) Equals(item1, item2 interface{}) bool

func (*CompareHelper) IsArray

func (instance *CompareHelper) IsArray(val interface{}) (bool, reflect.Value)

func (*CompareHelper) IsArrayNotEmpty

func (instance *CompareHelper) IsArrayNotEmpty(array interface{}) (bool, reflect.Value)

func (*CompareHelper) IsArrayValue

func (instance *CompareHelper) IsArrayValue(val interface{}) bool

func (*CompareHelper) IsBool

func (instance *CompareHelper) IsBool(val interface{}) (bool, bool)

func (*CompareHelper) IsBoolValue

func (instance *CompareHelper) IsBoolValue(val interface{}) bool

func (*CompareHelper) IsFloat32

func (instance *CompareHelper) IsFloat32(val interface{}) (bool, float32)

func (*CompareHelper) IsFloat32Value

func (instance *CompareHelper) IsFloat32Value(val interface{}) bool

func (*CompareHelper) IsFloat64

func (instance *CompareHelper) IsFloat64(val interface{}) (bool, float64)

func (*CompareHelper) IsFloat64Value

func (instance *CompareHelper) IsFloat64Value(val interface{}) bool

func (*CompareHelper) IsGreater

func (instance *CompareHelper) IsGreater(item1, item2 interface{}) bool

func (*CompareHelper) IsIn16

func (instance *CompareHelper) IsIn16(val interface{}) (bool, int16)

func (*CompareHelper) IsIn32

func (instance *CompareHelper) IsIn32(val interface{}) (bool, int32)

func (*CompareHelper) IsIn64

func (instance *CompareHelper) IsIn64(val interface{}) (bool, int64)

func (*CompareHelper) IsIn8

func (instance *CompareHelper) IsIn8(val interface{}) (bool, int8)

func (*CompareHelper) IsInt

func (instance *CompareHelper) IsInt(val interface{}) (bool, int)

func (*CompareHelper) IsInt16Value

func (instance *CompareHelper) IsInt16Value(val interface{}) bool

func (*CompareHelper) IsInt32Value

func (instance *CompareHelper) IsInt32Value(val interface{}) bool

func (*CompareHelper) IsInt64Value

func (instance *CompareHelper) IsInt64Value(val interface{}) bool

func (*CompareHelper) IsInt8Value

func (instance *CompareHelper) IsInt8Value(val interface{}) bool

func (*CompareHelper) IsIntValue

func (instance *CompareHelper) IsIntValue(val interface{}) bool

func (*CompareHelper) IsLower

func (instance *CompareHelper) IsLower(item1, item2 interface{}) bool

func (*CompareHelper) IsMap

func (instance *CompareHelper) IsMap(val interface{}) (bool, reflect.Value)

func (*CompareHelper) IsMapValue

func (instance *CompareHelper) IsMapValue(val interface{}) bool

func (*CompareHelper) IsNumeric

func (instance *CompareHelper) IsNumeric(val interface{}) (bool, float64)

func (*CompareHelper) IsPtrValue

func (instance *CompareHelper) IsPtrValue(val interface{}) bool

func (*CompareHelper) IsSliceValue

func (instance *CompareHelper) IsSliceValue(val interface{}) bool

func (*CompareHelper) IsString

func (instance *CompareHelper) IsString(val interface{}) (bool, string)

func (*CompareHelper) IsStringASCII

func (instance *CompareHelper) IsStringASCII(val string) bool

func (*CompareHelper) IsStringValue

func (instance *CompareHelper) IsStringValue(val interface{}) bool

func (*CompareHelper) IsStruct

func (instance *CompareHelper) IsStruct(val interface{}) (bool, reflect.Value)

func (*CompareHelper) IsStructValue

func (instance *CompareHelper) IsStructValue(val interface{}) bool

func (*CompareHelper) IsUint

func (instance *CompareHelper) IsUint(val interface{}) (bool, uint)

func (*CompareHelper) IsUint16

func (instance *CompareHelper) IsUint16(val interface{}) (bool, uint16)

func (*CompareHelper) IsUint16Value

func (instance *CompareHelper) IsUint16Value(val interface{}) bool

func (*CompareHelper) IsUint32

func (instance *CompareHelper) IsUint32(val interface{}) (bool, uint32)

func (*CompareHelper) IsUint32Value

func (instance *CompareHelper) IsUint32Value(val interface{}) bool

func (*CompareHelper) IsUint64

func (instance *CompareHelper) IsUint64(val interface{}) (bool, uint64)

func (*CompareHelper) IsUint8

func (instance *CompareHelper) IsUint8(val interface{}) (bool, uint8)

func (*CompareHelper) IsUint8Value

func (instance *CompareHelper) IsUint8Value(val interface{}) bool

func (*CompareHelper) IsUintPtrValue

func (instance *CompareHelper) IsUintPtrValue(val interface{}) bool

func (*CompareHelper) IsUintValue

func (instance *CompareHelper) IsUintValue(val interface{}) bool

func (*CompareHelper) IsZero

func (instance *CompareHelper) IsZero(item interface{}) bool

func (*CompareHelper) NotEquals

func (instance *CompareHelper) NotEquals(val1, val2 interface{}) bool

type ConcurrentPool

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

func (*ConcurrentPool) Count

func (instance *ConcurrentPool) Count() int32

func (*ConcurrentPool) IsRunning added in v0.2.50

func (instance *ConcurrentPool) IsRunning() bool

func (*ConcurrentPool) Limit

func (instance *ConcurrentPool) Limit() int

func (*ConcurrentPool) Run

func (instance *ConcurrentPool) Run(f GoRoutineWrapper) int

func (*ConcurrentPool) RunArgs

func (instance *ConcurrentPool) RunArgs(f GoRoutineWrapperArgs, args ...interface{}) int

RunArgs Execute adds a function to the execution queue. If num of go routines allocated by this instance is < limit launch a new go routine to execute job else wait until a go routine becomes available

func (*ConcurrentPool) Wait

func (instance *ConcurrentPool) Wait() *gg_errors.Error

Wait all jobs are executed, if any in queue

type ConversionHelper

type ConversionHelper struct {
}
var Convert *ConversionHelper

func (*ConversionHelper) ForceMap

func (instance *ConversionHelper) ForceMap(val interface{}) map[string]interface{}

func (*ConversionHelper) ForceMapOfString

func (instance *ConversionHelper) ForceMapOfString(val interface{}) map[string]string

func (*ConversionHelper) Int8ToStr

func (instance *ConversionHelper) Int8ToStr(arr []int8) string

func (*ConversionHelper) Num2Word

func (instance *ConversionHelper) Num2Word(args ...interface{}) string

func (*ConversionHelper) StringToNumber

func (instance *ConversionHelper) StringToNumber(s string, def interface{}) interface{}

func (*ConversionHelper) ToArray

func (instance *ConversionHelper) ToArray(val ...interface{}) []interface{}

func (*ConversionHelper) ToArrayOfByte

func (instance *ConversionHelper) ToArrayOfByte(val interface{}) []byte

func (*ConversionHelper) ToArrayOfFloat32

func (instance *ConversionHelper) ToArrayOfFloat32(val interface{}) []float32

func (*ConversionHelper) ToArrayOfFloat64

func (instance *ConversionHelper) ToArrayOfFloat64(val interface{}) []float64

func (*ConversionHelper) ToArrayOfInt

func (instance *ConversionHelper) ToArrayOfInt(val interface{}) []int

func (*ConversionHelper) ToArrayOfInt16

func (instance *ConversionHelper) ToArrayOfInt16(val interface{}) []int16

func (*ConversionHelper) ToArrayOfInt32

func (instance *ConversionHelper) ToArrayOfInt32(val interface{}) []int32

func (*ConversionHelper) ToArrayOfInt64

func (instance *ConversionHelper) ToArrayOfInt64(val interface{}) []int64

func (*ConversionHelper) ToArrayOfInt8

func (instance *ConversionHelper) ToArrayOfInt8(val interface{}) []int8

func (*ConversionHelper) ToArrayOfString

func (instance *ConversionHelper) ToArrayOfString(val ...interface{}) []string

func (*ConversionHelper) ToArrayOfUrlEncodedString

func (instance *ConversionHelper) ToArrayOfUrlEncodedString(val ...interface{}) (response []string)

func (*ConversionHelper) ToBool

func (instance *ConversionHelper) ToBool(val interface{}) bool

func (*ConversionHelper) ToDuration

func (instance *ConversionHelper) ToDuration(val interface{}) time.Duration

func (*ConversionHelper) ToEsaBytes

func (instance *ConversionHelper) ToEsaBytes(val int64) float64

func (*ConversionHelper) ToFloat32

func (instance *ConversionHelper) ToFloat32(val interface{}) float32

func (*ConversionHelper) ToFloat32Def

func (instance *ConversionHelper) ToFloat32Def(val interface{}, defVal float32) float32

func (*ConversionHelper) ToFloat64

func (instance *ConversionHelper) ToFloat64(val interface{}) float64

func (*ConversionHelper) ToFloat64Def

func (instance *ConversionHelper) ToFloat64Def(val interface{}, defVal float64) float64

func (*ConversionHelper) ToGigaBytes

func (instance *ConversionHelper) ToGigaBytes(val int64) float64

func (*ConversionHelper) ToInt

func (instance *ConversionHelper) ToInt(val interface{}) int

func (*ConversionHelper) ToInt16

func (instance *ConversionHelper) ToInt16(val interface{}) int16

func (*ConversionHelper) ToInt16Def

func (instance *ConversionHelper) ToInt16Def(val interface{}, defVal int16) int16

func (*ConversionHelper) ToInt32

func (instance *ConversionHelper) ToInt32(val interface{}) int32

func (*ConversionHelper) ToInt32Def

func (instance *ConversionHelper) ToInt32Def(val interface{}, defVal int32) int32

func (*ConversionHelper) ToInt64

func (instance *ConversionHelper) ToInt64(val interface{}) int64

func (*ConversionHelper) ToInt64Def

func (instance *ConversionHelper) ToInt64Def(val interface{}, defVal int64) int64

func (*ConversionHelper) ToInt8

func (instance *ConversionHelper) ToInt8(val interface{}) int8

func (*ConversionHelper) ToInt8Def

func (instance *ConversionHelper) ToInt8Def(val interface{}, defVal int8) int8

func (*ConversionHelper) ToIntDef

func (instance *ConversionHelper) ToIntDef(val interface{}, def int) int

func (*ConversionHelper) ToKiloBytes

func (instance *ConversionHelper) ToKiloBytes(val int64) float64

func (*ConversionHelper) ToLowerNames

func (instance *ConversionHelper) ToLowerNames(m map[string]interface{}) (response map[string]interface{})

func (*ConversionHelper) ToMap

func (instance *ConversionHelper) ToMap(val interface{}) map[string]interface{}

func (*ConversionHelper) ToMapOfString

func (instance *ConversionHelper) ToMapOfString(val interface{}) map[string]string

func (*ConversionHelper) ToMapOfStringArray

func (instance *ConversionHelper) ToMapOfStringArray(val interface{}) map[string][]string

func (*ConversionHelper) ToMegaBytes

func (instance *ConversionHelper) ToMegaBytes(val int64) float64

func (*ConversionHelper) ToPetaBytes

func (instance *ConversionHelper) ToPetaBytes(val int64) float64

func (*ConversionHelper) ToString

func (instance *ConversionHelper) ToString(val interface{}) string

func (*ConversionHelper) ToStringQuoted

func (instance *ConversionHelper) ToStringQuoted(val interface{}) string

func (*ConversionHelper) ToTeraBytes

func (instance *ConversionHelper) ToTeraBytes(val int64) float64

func (*ConversionHelper) ToUrlQuery

func (instance *ConversionHelper) ToUrlQuery(params map[string]interface{}) string

type CsvHelper

type CsvHelper struct {
}
var CSV *CsvHelper

func (*CsvHelper) AppendFile

func (instance *CsvHelper) AppendFile(data []map[string]interface{}, options *CsvOptions, filename string) (err error)

func (*CsvHelper) NewCsvOptions

func (instance *CsvHelper) NewCsvOptions(comma string, comment string, firstRowHeader bool) *CsvOptions

func (*CsvHelper) NewCsvOptionsDefaults

func (instance *CsvHelper) NewCsvOptionsDefaults() *CsvOptions

func (*CsvHelper) ReadAll

func (instance *CsvHelper) ReadAll(in string, options *CsvOptions) (response []map[string]string, err error)

func (*CsvHelper) WriteAll

func (instance *CsvHelper) WriteAll(data []map[string]interface{}, options *CsvOptions) (response string, err error)

func (*CsvHelper) WriteFile

func (instance *CsvHelper) WriteFile(data []map[string]interface{}, options *CsvOptions, filename string) (err error)

type CsvOptions

type CsvOptions struct {
	Comma          string `json:"comma"`
	Comment        string `json:"comment"`
	FirstRowHeader bool   `json:"first_row_header"`
}

type DatesHelper

type DatesHelper struct {
}
var Dates *DatesHelper

func (*DatesHelper) Add

func (instance *DatesHelper) Add(date interface{}, duration time.Duration) time.Time

func (*DatesHelper) AddDate

func (instance *DatesHelper) AddDate(date interface{}, years, months, days int) time.Time

func (*DatesHelper) AddDays

func (instance *DatesHelper) AddDays(date interface{}, days int) time.Time

func (*DatesHelper) AddMonths

func (instance *DatesHelper) AddMonths(date interface{}, months int) time.Time

func (*DatesHelper) AddWeeks

func (instance *DatesHelper) AddWeeks(date interface{}, weeks int) time.Time

func (*DatesHelper) AddYears

func (instance *DatesHelper) AddYears(date interface{}, years int) time.Time

func (*DatesHelper) AdjustDaylight

func (instance *DatesHelper) AdjustDaylight(t time.Time, loc string) time.Time

func (*DatesHelper) ExpiredDuration

func (instance *DatesHelper) ExpiredDuration(date1 interface{}, check time.Duration) bool

func (*DatesHelper) FirstAndLastOfMonth

func (instance *DatesHelper) FirstAndLastOfMonth(date interface{}, keepTime bool) (firstOfMonth time.Time, lastOfMonth time.Time)

func (*DatesHelper) FirstDayOfMonth

func (instance *DatesHelper) FirstDayOfMonth(date interface{}, day time.Weekday, includeDate, keepTime bool) time.Time

func (*DatesHelper) FormatDate

func (instance *DatesHelper) FormatDate(dt time.Time, pattern string) string

func (*DatesHelper) FormatDateLocale

func (instance *DatesHelper) FormatDateLocale(dt time.Time, lang string) string

func (*DatesHelper) GetLocation

func (instance *DatesHelper) GetLocation(loc string) *time.Location

GetLocation return a location from https://www.iana.org/time-zones

func (*DatesHelper) GetLocationDefault

func (instance *DatesHelper) GetLocationDefault() *time.Location

func (*DatesHelper) IsZero

func (instance *DatesHelper) IsZero(value interface{}) bool

func (*DatesHelper) LastDayOfMonth

func (instance *DatesHelper) LastDayOfMonth(date interface{}, day time.Weekday, includeDate, keepTime bool) time.Time

func (*DatesHelper) MustParse

func (instance *DatesHelper) MustParse(dateStr string) time.Time

MustParse parse a date, and panic if it can't be parsed. Used for testing. Not recommended for most use-cases.

func (*DatesHelper) NextWeekday

func (instance *DatesHelper) NextWeekday(date interface{}, day time.Weekday, includeDate bool) time.Time

func (*DatesHelper) ParseAny

func (instance *DatesHelper) ParseAny(any interface{}) (time.Time, error)

ParseAny parse an unknown date format, detect the layout. Normal parse. Equivalent Timezone rules as time.Parse().

func (*DatesHelper) ParseDate

func (instance *DatesHelper) ParseDate(dt string, pattern string) (time.Time, error)

func (*DatesHelper) ParseFormat

func (instance *DatesHelper) ParseFormat(dateStr string) (string, error)

ParseFormat parse's an unknown date-time string and returns a layout string that can parse this (and exact same format) other date-time strings.

layout, err := dateparse.ParseFormat("2013-02-01 00:00:00")
// layout = "2006-01-02 15:04:05"

func (*DatesHelper) ParseIn

func (instance *DatesHelper) ParseIn(dateStr string, loc *time.Location) (time.Time, error)

ParseIn with Location, equivalent to time.ParseInLocation() timezone/offset rules. Using location arg, if timezone/offset info exists in the dateStr, it uses the given location rules for any zone interpretation. That is, MST means one thing when using America/Denver and something else in other locations.

func (*DatesHelper) ParseLocal

func (instance *DatesHelper) ParseLocal(dateStr string) (time.Time, error)

ParseLocal Given an unknown date format, detect the layout, using time.Local, parse.

Set Location to time.Local. Same as ParseIn Location but lazily uses the global time.Local variable for Location argument.

denverLoc, _ := time.LoadLocation("America/Denver")
time.Local = denverLoc

t, err := dateparse.ParseLocal("3/1/2014")

Equivalent to:

t, err := dateparse.ParseIn("3/1/2014", denverLoc)

func (*DatesHelper) ParseStrict

func (instance *DatesHelper) ParseStrict(dateStr string) (time.Time, error)

ParseStrict parse an unknown date format. IF the date is ambigous mm/dd vs dd/mm then return an error. These return errors: 3.3.2014 , 8/8/71 etc

func (*DatesHelper) Sub

func (instance *DatesHelper) Sub(date1 interface{}, date2 interface{}) time.Duration

func (*DatesHelper) ToDateTime

func (instance *DatesHelper) ToDateTime(value interface{}) (t time.Time)

func (*DatesHelper) TryParseAny

func (instance *DatesHelper) TryParseAny(any interface{}) (time.Time, error)

type DirCentral

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

func (*DirCentral) DirRoot

func (instance *DirCentral) DirRoot() string

func (*DirCentral) DirTemp

func (instance *DirCentral) DirTemp() string

func (*DirCentral) DirWork

func (instance *DirCentral) DirWork() string

func (*DirCentral) GetPath

func (instance *DirCentral) GetPath(path string) (response string)

func (*DirCentral) GetTempPath

func (instance *DirCentral) GetTempPath(subPath string) (response string)

func (*DirCentral) GetWorkPath

func (instance *DirCentral) GetWorkPath(subPath string) (response string)

func (*DirCentral) PathLog

func (instance *DirCentral) PathLog() string

func (*DirCentral) Refresh

func (instance *DirCentral) Refresh()

func (*DirCentral) SetRoot

func (instance *DirCentral) SetRoot(dir string) *DirCentral

func (*DirCentral) SetSubTemp

func (instance *DirCentral) SetSubTemp(enabled bool) *DirCentral

func (*DirCentral) SetTemp

func (instance *DirCentral) SetTemp(dir string) *DirCentral

type DirHelper

type DirHelper struct {
}
var Dir *DirHelper

func (*DirHelper) NewCentral

func (instance *DirHelper) NewCentral(workPath, tempPath string, createSubTemp bool) (response *DirCentral)

type DownloadSession

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

func (*DownloadSession) DownloadAll

func (instance *DownloadSession) DownloadAll(force bool) ([]string, []error)

type Downloader

type Downloader struct {
	Actions map[string]*DownloaderAction
}

func (*Downloader) Download

func (instance *Downloader) Download(uid string) (files []string, err error)

func (*Downloader) DownloadAll

func (instance *Downloader) DownloadAll() ([]string, []error)

func (*Downloader) ForceDownload

func (instance *Downloader) ForceDownload(uid string) (files []string, err error)

func (*Downloader) ForceDownloadAll

func (instance *Downloader) ForceDownloadAll() ([]string, []error)

func (*Downloader) Names

func (instance *Downloader) Names() []string

func (*Downloader) Put

func (instance *Downloader) Put(action *DownloaderAction) *Downloader

func (*Downloader) PutAction

func (instance *Downloader) PutAction(uid, source, sourceversion, target string) *Downloader

type DownloaderAction

type DownloaderAction struct {
	Uid           string `json:"uid"`
	Source        string `json:"source"`
	SourceVersion string `json:"source-version"`
	Target        string `json:"target"`
}

type ExpressionTag

type ExpressionTag struct {
	Expression    string  `json:"expression"`
	SuccessWeight float32 `json:"success-weight"` // applied to existing keywords
	FailWeight    float32 `json:"fails-weight"`   // applied for missing keywords
}

func ParseExpression

func ParseExpression(text string) (tag *ExpressionTag)

func (*ExpressionTag) FailWeightOf

func (instance *ExpressionTag) FailWeightOf(value float32) float32

func (*ExpressionTag) Json

func (instance *ExpressionTag) Json() string

func (*ExpressionTag) String

func (instance *ExpressionTag) String() string

func (*ExpressionTag) SuccessWeightOf

func (instance *ExpressionTag) SuccessWeightOf(value float32) float32

type FileChunker

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

func NewFileChunker

func NewFileChunker(chunkSizeBytes int64) (instance *FileChunker)

func NewFileChunkerLarge

func NewFileChunkerLarge() (instance *FileChunker)

func NewFileChunkerMedium

func NewFileChunkerMedium() (instance *FileChunker)

func NewFileChunkerSmall

func NewFileChunkerSmall() (instance *FileChunker)

func (*FileChunker) CalculateChunks

func (instance *FileChunker) CalculateChunks(filename string) (fileSize int64, totalPartsNum uint64, err error)

func (*FileChunker) SplitAll

func (instance *FileChunker) SplitAll(filename string) (response [][]byte, err error)

func (*FileChunker) SplitWalk

func (instance *FileChunker) SplitWalk(filename string, callback func(data []byte)) (err error)

type FileWriter added in v0.2.38

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

func NewFileWriter added in v0.2.38

func NewFileWriter(args ...interface{}) (instance *FileWriter, err error)

func (*FileWriter) Options added in v0.2.38

func (instance *FileWriter) Options() (response *FileWriterOptions)

func (*FileWriter) Rotate added in v0.2.38

func (instance *FileWriter) Rotate() (err error)

func (*FileWriter) SetAppend added in v0.2.38

func (instance *FileWriter) SetAppend(value bool) *FileWriter

func (*FileWriter) SetFilename added in v0.2.38

func (instance *FileWriter) SetFilename(value string) *FileWriter

func (*FileWriter) SetRotateDir added in v0.2.38

func (instance *FileWriter) SetRotateDir(value string) *FileWriter

func (*FileWriter) SetRotateDirLimit added in v0.2.38

func (instance *FileWriter) SetRotateDirLimit(value int) *FileWriter

func (*FileWriter) SetRotateMode added in v0.2.38

func (instance *FileWriter) SetRotateMode(value string) *FileWriter

func (*FileWriter) String added in v0.2.38

func (instance *FileWriter) String() string

func (*FileWriter) Write added in v0.2.38

func (instance *FileWriter) Write(data []byte) (n int, err error)

type FileWriterOptions added in v0.2.38

type FileWriterOptions struct {
	Filename       string `json:"filename"`
	Append         bool   `json:"append"`
	RotateDir      string `json:"rotate-dir"`       // if assigned, write old files into this dir
	RotateDirLimit int    `json:"rotate-dir-limit"` // max number of files in dir
	RotateMode     string `json:"rotate-mode"`      // size:BYTES, time:SECONDS
}

type FormatterHelper

type FormatterHelper struct {
}
var Formatter *FormatterHelper

func (*FormatterHelper) FormatBytes

func (instance *FormatterHelper) FormatBytes(i interface{}) string

func (*FormatterHelper) FormatDate

func (instance *FormatterHelper) FormatDate(dt time.Time, pattern string) string

func (*FormatterHelper) FormatFloat

func (instance *FormatterHelper) FormatFloat(i interface{}, pattern string) string

func (*FormatterHelper) FormatInteger

func (instance *FormatterHelper) FormatInteger(i interface{}, pattern string) string

func (*FormatterHelper) FormatMap

func (instance *FormatterHelper) FormatMap(i interface{}) string

func (*FormatterHelper) Merge

func (instance *FormatterHelper) Merge(textOrHtml string, data interface{}) (string, error)

func (*FormatterHelper) MergeDef

func (instance *FormatterHelper) MergeDef(textOrHtml string, data interface{}, def string) (string, error)

func (*FormatterHelper) MergeDefKeepFields

func (instance *FormatterHelper) MergeDefKeepFields(textOrHtml string, data interface{}, def string) (string, error)

func (*FormatterHelper) MergeHtml

func (instance *FormatterHelper) MergeHtml(html string, data interface{}) (string, error)

func (*FormatterHelper) MergeHtmlDef

func (instance *FormatterHelper) MergeHtmlDef(text string, data interface{}, def string) (string, error)

func (*FormatterHelper) MergeHtmlKeepFields

func (instance *FormatterHelper) MergeHtmlKeepFields(html string, data interface{}) (string, error)

func (*FormatterHelper) MergeHtmlRecover

func (instance *FormatterHelper) MergeHtmlRecover(text string, data interface{}, def string, callback func(string, error))

func (*FormatterHelper) MergeKeepFields

func (instance *FormatterHelper) MergeKeepFields(textOrHtml string, data interface{}) (string, error)

func (*FormatterHelper) MergeRecover

func (instance *FormatterHelper) MergeRecover(textOrHtml string, data interface{}, def string, callback func(string, error))

func (*FormatterHelper) MergeText

func (instance *FormatterHelper) MergeText(text string, data interface{}) (string, error)

func (*FormatterHelper) MergeTextDef

func (instance *FormatterHelper) MergeTextDef(text string, data interface{}, def string) (string, error)

func (*FormatterHelper) MergeTextKeepFields

func (instance *FormatterHelper) MergeTextKeepFields(text string, data interface{}) (string, error)

func (*FormatterHelper) MergeTextRecover

func (instance *FormatterHelper) MergeTextRecover(text string, data interface{}, def string, callback func(string, error))

func (*FormatterHelper) ParseDate

func (instance *FormatterHelper) ParseDate(dt string, pattern string) (time.Time, error)

func (*FormatterHelper) Render

func (instance *FormatterHelper) Render(s string, data interface{}, allowEmpty bool) string

type GoRoutineWrapper

type GoRoutineWrapper func() error

type GoRoutineWrapperArgs

type GoRoutineWrapperArgs func(args ...interface{}) error

type IoHelper

type IoHelper struct {
}
var IO *IoHelper

func (*IoHelper) AppendBytesToFile

func (instance *IoHelper) AppendBytesToFile(data []byte, filename string) (int, error)

func (*IoHelper) AppendTextToFile

func (instance *IoHelper) AppendTextToFile(text, filename string) (int, error)

func (*IoHelper) Chmod

func (instance *IoHelper) Chmod(filename string, mode os.FileMode) (changed bool, err error)

func (*IoHelper) CopyFile

func (instance *IoHelper) CopyFile(src, dst string) (int64, error)

func (*IoHelper) Download

func (instance *IoHelper) Download(url string) ([]byte, error)

func (*IoHelper) FileModTime added in v0.2.38

func (instance *IoHelper) FileModTime(filename string) (time.Time, error)

func (*IoHelper) FileModTimeDiff added in v0.2.38

func (instance *IoHelper) FileModTimeDiff(filename string, from time.Time) (time.Duration, error)

func (*IoHelper) FileModTimeDiffIsGreaterThan added in v0.2.38

func (instance *IoHelper) FileModTimeDiffIsGreaterThan(filename string, from time.Time, check time.Duration) bool

func (*IoHelper) FileSize

func (instance *IoHelper) FileSize(filename string) (int64, error)

func (*IoHelper) MoveFile

func (instance *IoHelper) MoveFile(from, to string) error

func (*IoHelper) NewDownloadSession

func (instance *IoHelper) NewDownloadSession(actions interface{}) *DownloadSession

func (*IoHelper) NewDownloader

func (instance *IoHelper) NewDownloader() *Downloader

func (*IoHelper) NewDownloaderAction

func (instance *IoHelper) NewDownloaderAction(uid, source, sourceversion, target string) *DownloaderAction

func (*IoHelper) NewFileWriter added in v0.2.38

func (instance *IoHelper) NewFileWriter(args ...interface{}) (*FileWriter, error)

func (*IoHelper) ReadAllBytes

func (instance *IoHelper) ReadAllBytes(reader io.Reader) ([]byte, error)

func (*IoHelper) ReadAllString

func (instance *IoHelper) ReadAllString(reader io.Reader) (string, error)

func (*IoHelper) ReadBytesFromFile

func (instance *IoHelper) ReadBytesFromFile(fileName string) ([]byte, error)

func (*IoHelper) ReadHashFromBytes

func (instance *IoHelper) ReadHashFromBytes(data []byte) (string, error)

func (*IoHelper) ReadHashFromFile

func (instance *IoHelper) ReadHashFromFile(fileName string) (string, error)

func (*IoHelper) ReadLinesFromFile

func (instance *IoHelper) ReadLinesFromFile(fileName string, count int) string

func (*IoHelper) ReadTextFromFile

func (instance *IoHelper) ReadTextFromFile(fileName string) (string, error)

func (*IoHelper) Remove

func (instance *IoHelper) Remove(filename string) error

func (*IoHelper) RemoveAll

func (instance *IoHelper) RemoveAll(path string) error

func (*IoHelper) RemoveAllSilent

func (instance *IoHelper) RemoveAllSilent(path string)

func (*IoHelper) RemoveSilent

func (instance *IoHelper) RemoveSilent(filename string)

func (*IoHelper) ScanBytesFromFile

func (instance *IoHelper) ScanBytesFromFile(fileName string, callback func(data []byte) bool) error

ScanBytesFromFile read a file line by line

func (*IoHelper) ScanTextFromFile

func (instance *IoHelper) ScanTextFromFile(fileName string, callback func(text string) bool) error

ScanTextFromFile read a text file line by line

func (*IoHelper) WriteBytesToFile

func (instance *IoHelper) WriteBytesToFile(data []byte, filename string) (int, error)

func (*IoHelper) WriteTextToFile

func (instance *IoHelper) WriteTextToFile(text, filename string) (int, error)

type MIMEHelper

type MIMEHelper struct {
}
var MIME *MIMEHelper

func (*MIMEHelper) GetMimeTypeByExtension

func (instance *MIMEHelper) GetMimeTypeByExtension(ext string) string

type MapsHelper

type MapsHelper struct {
}
var Maps *MapsHelper

func (*MapsHelper) Clone

func (instance *MapsHelper) Clone(m map[string]interface{}) map[string]interface{}

func (*MapsHelper) Get

func (instance *MapsHelper) Get(m map[string]interface{}, path string) interface{}

func (*MapsHelper) GetAll

func (instance *MapsHelper) GetAll(m map[string]interface{}, paths ...string) (response []interface{}, success bool)

func (*MapsHelper) GetArray

func (instance *MapsHelper) GetArray(m map[string]interface{}, path string) []interface{}

func (*MapsHelper) GetArrayOfByte

func (instance *MapsHelper) GetArrayOfByte(m map[string]interface{}, path string) []byte

func (*MapsHelper) GetArrayOfString

func (instance *MapsHelper) GetArrayOfString(m map[string]interface{}, path string) []string

func (*MapsHelper) GetBool

func (instance *MapsHelper) GetBool(m map[string]interface{}, path string) bool

func (*MapsHelper) GetBytes

func (instance *MapsHelper) GetBytes(m map[string]interface{}, path string) []byte

func (*MapsHelper) GetFloat32

func (instance *MapsHelper) GetFloat32(m map[string]interface{}, path string) float32

func (*MapsHelper) GetFloat64

func (instance *MapsHelper) GetFloat64(m map[string]interface{}, path string) float64

func (*MapsHelper) GetInt

func (instance *MapsHelper) GetInt(m map[string]interface{}, path string) int

func (*MapsHelper) GetInt16

func (instance *MapsHelper) GetInt16(m map[string]interface{}, path string) int16

func (*MapsHelper) GetInt32

func (instance *MapsHelper) GetInt32(m map[string]interface{}, path string) int32

func (*MapsHelper) GetInt64

func (instance *MapsHelper) GetInt64(m map[string]interface{}, path string) int64

func (*MapsHelper) GetInt8

func (instance *MapsHelper) GetInt8(m map[string]interface{}, path string) int8

func (*MapsHelper) GetMany

func (instance *MapsHelper) GetMany(m map[string]interface{}, paths ...string) (response []interface{})

func (*MapsHelper) GetMap

func (instance *MapsHelper) GetMap(m map[string]interface{}, path string) map[string]interface{}

func (*MapsHelper) GetMapOfString

func (instance *MapsHelper) GetMapOfString(m map[string]interface{}, path string) map[string]string

func (*MapsHelper) GetMapOfStringArray

func (instance *MapsHelper) GetMapOfStringArray(m map[string]interface{}, path string) map[string][]string

func (*MapsHelper) GetOne

func (instance *MapsHelper) GetOne(m map[string]interface{}, paths ...string) (response interface{})

func (*MapsHelper) GetOneBool

func (instance *MapsHelper) GetOneBool(m map[string]interface{}, paths ...string) bool

func (*MapsHelper) GetOneBytes

func (instance *MapsHelper) GetOneBytes(m map[string]interface{}, paths ...string) []byte

func (*MapsHelper) GetOneFloat32

func (instance *MapsHelper) GetOneFloat32(m map[string]interface{}, paths ...string) float32

func (*MapsHelper) GetOneFloat64

func (instance *MapsHelper) GetOneFloat64(m map[string]interface{}, paths ...string) float64

func (*MapsHelper) GetOneInt

func (instance *MapsHelper) GetOneInt(m map[string]interface{}, paths ...string) int

func (*MapsHelper) GetOneInt16

func (instance *MapsHelper) GetOneInt16(m map[string]interface{}, paths ...string) int16

func (*MapsHelper) GetOneInt32

func (instance *MapsHelper) GetOneInt32(m map[string]interface{}, paths ...string) int32

func (*MapsHelper) GetOneInt64

func (instance *MapsHelper) GetOneInt64(m map[string]interface{}, paths ...string) int64

func (*MapsHelper) GetOneInt8

func (instance *MapsHelper) GetOneInt8(m map[string]interface{}, paths ...string) int8

func (*MapsHelper) GetOneString

func (instance *MapsHelper) GetOneString(m map[string]interface{}, paths ...string) string

func (*MapsHelper) GetOneUint

func (instance *MapsHelper) GetOneUint(m map[string]interface{}, paths ...string) uint

func (*MapsHelper) GetOneUint16

func (instance *MapsHelper) GetOneUint16(m map[string]interface{}, paths ...string) uint16

func (*MapsHelper) GetOneUint32

func (instance *MapsHelper) GetOneUint32(m map[string]interface{}, paths ...string) uint32

func (*MapsHelper) GetOneUint64

func (instance *MapsHelper) GetOneUint64(m map[string]interface{}, paths ...string) uint64

func (*MapsHelper) GetOneUint8

func (instance *MapsHelper) GetOneUint8(m map[string]interface{}, paths ...string) uint8

func (*MapsHelper) GetString

func (instance *MapsHelper) GetString(m map[string]interface{}, path string) string

func (*MapsHelper) GetUint

func (instance *MapsHelper) GetUint(m map[string]interface{}, path string) uint

func (*MapsHelper) GetUint16

func (instance *MapsHelper) GetUint16(m map[string]interface{}, path string) uint16

func (*MapsHelper) GetUint32

func (instance *MapsHelper) GetUint32(m map[string]interface{}, path string) uint32

func (*MapsHelper) GetUint64

func (instance *MapsHelper) GetUint64(m map[string]interface{}, path string) uint64

func (*MapsHelper) GetUint8

func (instance *MapsHelper) GetUint8(m map[string]interface{}, path string) uint8

func (*MapsHelper) KeyValuePairs

func (instance *MapsHelper) KeyValuePairs(m map[string]interface{}) ([]string, []interface{})

func (*MapsHelper) Keys

func (instance *MapsHelper) Keys(m map[string]interface{}) []string

func (*MapsHelper) Merge

func (instance *MapsHelper) Merge(overwrite bool, target map[string]interface{}, sources ...map[string]interface{}) map[string]interface{}

func (*MapsHelper) MergeCount

func (instance *MapsHelper) MergeCount(overwrite bool, target map[string]interface{}, sources ...map[string]interface{}) int

func (*MapsHelper) MergeExclusion

func (instance *MapsHelper) MergeExclusion(overwrite bool, exclusions []string, target map[string]interface{}, sources ...map[string]interface{}) map[string]interface{}

func (*MapsHelper) MergeFields

func (instance *MapsHelper) MergeFields(overwrite bool, target map[string]interface{}, sources ...map[string]interface{}) (fields []string)

func (*MapsHelper) Set

func (instance *MapsHelper) Set(m map[string]interface{}, path string, value interface{})

func (*MapsHelper) Values

func (instance *MapsHelper) Values(m map[string]interface{}) []interface{}

func (*MapsHelper) ValuesOfKeys

func (instance *MapsHelper) ValuesOfKeys(m map[string]interface{}, keys []string) []interface{}

type PathsHelper

type PathsHelper struct {
}
var Paths *PathsHelper

func (*PathsHelper) Absolute

func (instance *PathsHelper) Absolute(path string) string

func (*PathsHelper) Absolutize

func (instance *PathsHelper) Absolutize(path, root string) string

func (*PathsHelper) ChangeFileName

func (instance *PathsHelper) ChangeFileName(fromPath, toFileName string) string

func (*PathsHelper) ChangeFileNameExtension

func (instance *PathsHelper) ChangeFileNameExtension(fromPath, toFileExtension string) string

func (*PathsHelper) ChangeFileNameWithPrefix

func (instance *PathsHelper) ChangeFileNameWithPrefix(path, prefix string) string

func (*PathsHelper) ChangeFileNameWithSuffix

func (instance *PathsHelper) ChangeFileNameWithSuffix(path, suffix string) string

func (*PathsHelper) Clean

func (instance *PathsHelper) Clean(pathOrUrl string) string

func (*PathsHelper) CleanPath

func (instance *PathsHelper) CleanPath(p string) string

CleanPath returns the shortest path name equivalent to path by purely lexical processing. It applies the following rules iteratively until no further processing can be done:

  1. Replace multiple Separator elements with a single one.
  2. Eliminate each . path name element (the current directory).
  3. Eliminate each inner .. path name element (the parent directory) along with the non-.. element that precedes it.
  4. Eliminate .. elements that begin a rooted path: that is, replace "/.." by "/" at the beginning of a path, assuming Separator is '/'.

The returned path ends in a slash only if it represents a root directory, such as "/" on Unix or `C:\` on Windows.

Finally, any occurrences of slash are replaced by Separator.

If the result of this process is an empty string, Clean returns the string ".".

See also Rob Pike, “Lexical File Names in Plan 9 or Getting Dot-Dot Right,” https://9p.io/sys/doc/lexnames.html

func (*PathsHelper) CleanUrl

func (instance *PathsHelper) CleanUrl(p string) string

CleanUrl is the URL version of path.Clean, it returns a canonical URL path for p, eliminating . and .. elements.

The following rules are applied iteratively until no further processing can be done:

  1. Replace multiple slashes with a single slash.
  2. Eliminate each . path name element (the current directory).
  3. Eliminate each inner .. path name element (the parent directory) along with the non-.. element that precedes it.
  4. Eliminate .. elements that begin a rooted path: that is, replace "/.." by "/" at the beginning of a path.

If the result of this process is an empty string, "/" is returned

func (*PathsHelper) Concat

func (instance *PathsHelper) Concat(paths ...string) string

func (*PathsHelper) ConcatDir

func (instance *PathsHelper) ConcatDir(paths ...string) string

func (*PathsHelper) DatePath

func (instance *PathsHelper) DatePath(root, partial string, level int, autoCreate bool) string

DatePath return a date based path ex: "/2020/01/23/file.txt" @param root Root, starting directory @param partial File name @param level 1=Year, 2=Year/Month, 3=Year/Month/Day, 4=Year/Mont/Day/Hour, 5=Year/Mont/Day/Hour/Minute, 6=Year/Mont/Day/Hour/minute/Second @param autoCreate If true, creates directories

func (*PathsHelper) DateTimePath added in v0.2.52

func (instance *PathsHelper) DateTimePath(date time.Time, root, partial string, level int, autoCreate bool) string

func (*PathsHelper) Dir

func (instance *PathsHelper) Dir(path string) string

func (*PathsHelper) EnsureRelative added in v0.2.44

func (instance *PathsHelper) EnsureRelative(path string) (response string)

func (*PathsHelper) EnsureTrailingSlash

func (instance *PathsHelper) EnsureTrailingSlash(dir string) string

EnsureTrailingSlash add path separator to end if any.

func (*PathsHelper) Exists

func (instance *PathsHelper) Exists(path string) (bool, error)

Exists Check if a path exists and returns a boolean value or an error if access is denied @param path Path to check

func (*PathsHelper) Extension

func (instance *PathsHelper) Extension(path string) string

func (*PathsHelper) ExtensionName

func (instance *PathsHelper) ExtensionName(path string) string

func (*PathsHelper) FileName

func (instance *PathsHelper) FileName(path string, includeExt bool) string

func (*PathsHelper) GetTempRoot

func (instance *PathsHelper) GetTempRoot() string

func (*PathsHelper) GetWorkspace

func (instance *PathsHelper) GetWorkspace(name ...string) *Workspace

func (*PathsHelper) GetWorkspacePath

func (instance *PathsHelper) GetWorkspacePath() string

func (*PathsHelper) HasExtension

func (instance *PathsHelper) HasExtension(path, ext string) bool

func (*PathsHelper) IsAbs

func (instance *PathsHelper) IsAbs(path string) bool

func (*PathsHelper) IsDir

func (instance *PathsHelper) IsDir(path string) (bool, error)

func (*PathsHelper) IsDirPath

func (instance *PathsHelper) IsDirPath(path string) bool

func (*PathsHelper) IsFile

func (instance *PathsHelper) IsFile(path string) (bool, error)

func (*PathsHelper) IsFilePath

func (instance *PathsHelper) IsFilePath(path string) bool

func (*PathsHelper) IsHiddenFile

func (instance *PathsHelper) IsHiddenFile(path string) (bool, error)

func (*PathsHelper) IsPath

func (instance *PathsHelper) IsPath(path string) bool

IsPath get a string and check if is a valid path

func (*PathsHelper) IsSameFile

func (instance *PathsHelper) IsSameFile(path1, path2 string) (bool, error)

func (*PathsHelper) IsSameFileInfo

func (instance *PathsHelper) IsSameFileInfo(f1, f2 os.FileInfo) bool
func (instance *PathsHelper) IsSymLink(path string) (bool, error)

func (*PathsHelper) IsTemp

func (instance *PathsHelper) IsTemp(path string) bool

IsTemp return true if path is under "./_temp"

func (*PathsHelper) IsUrl

func (instance *PathsHelper) IsUrl(path string) bool

func (*PathsHelper) ListAll

func (instance *PathsHelper) ListAll(root string) ([]string, error)

func (*PathsHelper) ListDir

func (instance *PathsHelper) ListDir(root string) ([]string, error)

func (*PathsHelper) ListFiles

func (instance *PathsHelper) ListFiles(root string, rawFilter interface{}) ([]string, error)

func (*PathsHelper) Mkdir

func (instance *PathsHelper) Mkdir(path string) (err error)

Mkdir Creates a directory and all subdirectories if does not exists

func (*PathsHelper) NormalizePathForOS

func (instance *PathsHelper) NormalizePathForOS(path string) string

func (*PathsHelper) PatternMatchBase

func (instance *PathsHelper) PatternMatchBase(filename, pattern string) bool

func (*PathsHelper) ReadDir

func (instance *PathsHelper) ReadDir(root string) ([]string, error)

ReadDir reads the directory named by dirname and returns a list of file's and directory's name.

func (*PathsHelper) ReadDirOnly

func (instance *PathsHelper) ReadDirOnly(root string) ([]string, error)

func (*PathsHelper) ReadFileOnly

func (instance *PathsHelper) ReadFileOnly(root string) ([]string, error)

func (*PathsHelper) Relativize added in v0.2.44

func (instance *PathsHelper) Relativize(path string, root string) (response string)

func (*PathsHelper) SetTempRoot

func (instance *PathsHelper) SetTempRoot(path string)

func (*PathsHelper) SetWorkspaceParent

func (instance *PathsHelper) SetWorkspaceParent(value string)

func (*PathsHelper) SetWorkspacePath

func (instance *PathsHelper) SetWorkspacePath(value string)

func (*PathsHelper) TempPath

func (instance *PathsHelper) TempPath(partial string) string

func (*PathsHelper) TmpFile

func (instance *PathsHelper) TmpFile(extension string) string

func (*PathsHelper) TmpFileName

func (instance *PathsHelper) TmpFileName(extension string) string

func (*PathsHelper) UserHomeDir

func (instance *PathsHelper) UserHomeDir() (string, error)

func (*PathsHelper) UserHomePath

func (instance *PathsHelper) UserHomePath(path string) string

func (*PathsHelper) Walk

func (instance *PathsHelper) Walk(root, filter string, callback func(path string, info os.FileInfo) error) (err error)

func (*PathsHelper) WalkDir

func (instance *PathsHelper) WalkDir(root string, callback func(path string) error) (err error)

func (*PathsHelper) WalkFiles

func (instance *PathsHelper) WalkFiles(root string, filter string, callback func(path string) error) (err error)

func (*PathsHelper) WalkFilesOnOutput

func (instance *PathsHelper) WalkFilesOnOutput(root string, filter string, output io.Writer) (err error)

func (*PathsHelper) WalkFilesOnOutputFile

func (instance *PathsHelper) WalkFilesOnOutputFile(root string, filter string, filename string) (err error)

func (*PathsHelper) WorkspacePath

func (instance *PathsHelper) WorkspacePath(partial string) string

type ReflectHelper

type ReflectHelper struct {
}
var Reflect *ReflectHelper

func (*ReflectHelper) Get

func (instance *ReflectHelper) Get(object interface{}, name string) interface{}

func (*ReflectHelper) GetArray

func (instance *ReflectHelper) GetArray(object interface{}, name string) []interface{}

func (*ReflectHelper) GetArrayOfByte

func (instance *ReflectHelper) GetArrayOfByte(object interface{}, name string) []byte

func (*ReflectHelper) GetArrayOfInt

func (instance *ReflectHelper) GetArrayOfInt(object interface{}, name string) []int

func (*ReflectHelper) GetArrayOfInt16

func (instance *ReflectHelper) GetArrayOfInt16(object interface{}, name string) []int16

func (*ReflectHelper) GetArrayOfInt32

func (instance *ReflectHelper) GetArrayOfInt32(object interface{}, name string) []int32

func (*ReflectHelper) GetArrayOfInt64

func (instance *ReflectHelper) GetArrayOfInt64(object interface{}, name string) []int64

func (*ReflectHelper) GetArrayOfInt8

func (instance *ReflectHelper) GetArrayOfInt8(object interface{}, name string) []int8

func (*ReflectHelper) GetArrayOfString

func (instance *ReflectHelper) GetArrayOfString(object interface{}, name string) []string

func (*ReflectHelper) GetBool

func (instance *ReflectHelper) GetBool(object interface{}, name string) bool

func (*ReflectHelper) GetBytes

func (instance *ReflectHelper) GetBytes(object interface{}, name string) []byte

func (*ReflectHelper) GetFloat32

func (instance *ReflectHelper) GetFloat32(object interface{}, name string) float32

func (*ReflectHelper) GetFloat64

func (instance *ReflectHelper) GetFloat64(object interface{}, name string) float64

func (*ReflectHelper) GetInt

func (instance *ReflectHelper) GetInt(object interface{}, name string) int

func (*ReflectHelper) GetInt16 added in v0.2.61

func (instance *ReflectHelper) GetInt16(object interface{}, name string) int16

func (*ReflectHelper) GetInt32

func (instance *ReflectHelper) GetInt32(object interface{}, name string) int32

func (*ReflectHelper) GetInt64

func (instance *ReflectHelper) GetInt64(object interface{}, name string) int64

func (*ReflectHelper) GetInt8

func (instance *ReflectHelper) GetInt8(object interface{}, name string) int8

func (*ReflectHelper) GetMap

func (instance *ReflectHelper) GetMap(object interface{}, name string) map[string]interface{}

func (*ReflectHelper) GetMapOfString

func (instance *ReflectHelper) GetMapOfString(object interface{}, name string) map[string]string

func (*ReflectHelper) GetString

func (instance *ReflectHelper) GetString(object interface{}, name string) string

func (*ReflectHelper) GetUint

func (instance *ReflectHelper) GetUint(object interface{}, name string) uint

func (*ReflectHelper) GetUint16

func (instance *ReflectHelper) GetUint16(object interface{}, name string) uint16

func (*ReflectHelper) GetUint32

func (instance *ReflectHelper) GetUint32(object interface{}, name string) uint32

func (*ReflectHelper) GetUint64

func (instance *ReflectHelper) GetUint64(object interface{}, name string) uint64

func (*ReflectHelper) GetUint8

func (instance *ReflectHelper) GetUint8(object interface{}, name string) uint8

func (*ReflectHelper) InterfaceOf

func (instance *ReflectHelper) InterfaceOf(item interface{}) interface{}

func (*ReflectHelper) ValueOf

func (instance *ReflectHelper) ValueOf(item interface{}) reflect.Value

type RegexHelper

type RegexHelper struct {
}
var Regex *RegexHelper

func (*RegexHelper) BetweenBraces

func (instance *RegexHelper) BetweenBraces(text string) [][]string

func (*RegexHelper) BtcAddresses

func (instance *RegexHelper) BtcAddresses(text string) []string

BtcAddresses finds all bitcoin addresses

func (*RegexHelper) CreditCards

func (instance *RegexHelper) CreditCards(text string) []string

CreditCards finds all credit card numbers

func (*RegexHelper) Date

func (instance *RegexHelper) Date(text string) []string

Date finds all date strings

func (*RegexHelper) Emails

func (instance *RegexHelper) Emails(text string) []string

Emails finds all email strings

func (*RegexHelper) GUIDs

func (instance *RegexHelper) GUIDs(text string) []string

GUIDs finds all GUID strings

func (*RegexHelper) GetParamNames

func (instance *RegexHelper) GetParamNames(statement, prefix string, suffix interface{}) []string

GetParamNames return unique @param names

func (*RegexHelper) GetParamNamesAt

func (instance *RegexHelper) GetParamNamesAt(statement string) []string

func (*RegexHelper) GetParamNamesBraces

func (instance *RegexHelper) GetParamNamesBraces(statement string) []string

func (*RegexHelper) GitRepos

func (instance *RegexHelper) GitRepos(text string) []string

GitRepos finds all git repository addresses which have protocol prefix

func (*RegexHelper) HexColors

func (instance *RegexHelper) HexColors(text string) []string

HexColors finds all hex color values

func (*RegexHelper) IBANs

func (instance *RegexHelper) IBANs(text string) []string

IBANs finds all IBAN strings

func (*RegexHelper) IPs

func (instance *RegexHelper) IPs(text string) []string

IPs finds all IP addresses (both IPv4 and IPv6)

func (*RegexHelper) IPv4s

func (instance *RegexHelper) IPv4s(text string) []string

IPv4s finds all IPv4 addresses

func (*RegexHelper) IPv6s

func (instance *RegexHelper) IPv6s(text string) []string

IPv6s finds all IPv6 addresses

func (*RegexHelper) ISBN10s

func (instance *RegexHelper) ISBN10s(text string) []string

ISBN10s finds all ISBN10 strings

func (*RegexHelper) ISBN13s

func (instance *RegexHelper) ISBN13s(text string) []string

ISBN13s finds all ISBN13 strings

func (*RegexHelper) Index

func (instance *RegexHelper) Index(text string, pattern string, offset int) []int

func (*RegexHelper) IndexLenPair

func (instance *RegexHelper) IndexLenPair(text string, pattern string, offset int) [][]int

func (*RegexHelper) IsHTML

func (instance *RegexHelper) IsHTML(text string) bool

func (*RegexHelper) IsValidEmail

func (instance *RegexHelper) IsValidEmail(text string) bool

func (*RegexHelper) IsValidJsonArray

func (instance *RegexHelper) IsValidJsonArray(text string) bool

func (*RegexHelper) IsValidJsonObject

func (instance *RegexHelper) IsValidJsonObject(text string) bool
func (instance *RegexHelper) Links(text string) []string

Links finds all link strings

func (*RegexHelper) MACAddresses

func (instance *RegexHelper) MACAddresses(text string) []string

MACAddresses finds all MAC addresses

func (*RegexHelper) MCCreditCards

func (instance *RegexHelper) MCCreditCards(text string) []string

MCCreditCards finds all MasterCard credit card numbers

func (*RegexHelper) MD5Hexes

func (instance *RegexHelper) MD5Hexes(text string) []string

MD5Hexes finds all MD5 hex strings

func (*RegexHelper) Match

func (instance *RegexHelper) Match(text, expression string) []string

func (*RegexHelper) MatchAll

func (instance *RegexHelper) MatchAll(text, expression string) ([]string, [][]int)

func (*RegexHelper) MatchBetween

func (instance *RegexHelper) MatchBetween(text string, offset int, patternStart string, patternEnd string, cutset string) []string

func (*RegexHelper) MatchIndex

func (instance *RegexHelper) MatchIndex(text, expression string) [][]int

func (*RegexHelper) NormalizePhoneNumber

func (instance *RegexHelper) NormalizePhoneNumber(str string, prefix ...string) (response string)

NormalizePhoneNumber try to normalize a phone number. "3477857785"

func (*RegexHelper) NotKnownPorts

func (instance *RegexHelper) NotKnownPorts(text string) []string

NotKnownPorts finds all not-known port numbers

func (*RegexHelper) Numbers

func (instance *RegexHelper) Numbers(text string) []string

func (*RegexHelper) Phones

func (instance *RegexHelper) Phones(text string) []string

Phones finds all phone numbers

func (*RegexHelper) PhonesWithExts

func (instance *RegexHelper) PhonesWithExts(text string) []string

PhonesWithExts finds all phone numbers with ext

func (*RegexHelper) PoBoxes

func (instance *RegexHelper) PoBoxes(text string) []string

PoBoxes finds all po-box strings

func (*RegexHelper) Prices

func (instance *RegexHelper) Prices(text string) []string

Prices finds all price strings

func (*RegexHelper) SHA1Hexes

func (instance *RegexHelper) SHA1Hexes(text string) []string

SHA1Hexes finds all SHA1 hex strings

func (*RegexHelper) SHA256Hexes

func (instance *RegexHelper) SHA256Hexes(text string) []string

SHA256Hexes finds all SHA256 hex strings

func (*RegexHelper) SSNs

func (instance *RegexHelper) SSNs(text string) []string

SSNs finds all SSN strings

func (*RegexHelper) SanitizeHTML

func (instance *RegexHelper) SanitizeHTML(text string) (clean string)

func (*RegexHelper) SanitizeSQL

func (instance *RegexHelper) SanitizeSQL(text string) (clean string)

func (*RegexHelper) StreetAddresses

func (instance *RegexHelper) StreetAddresses(text string) []string

StreetAddresses finds all street addresses

func (*RegexHelper) TagsBetweenBraces

func (instance *RegexHelper) TagsBetweenBraces(text string) []string

func (*RegexHelper) TagsBetweenStrings

func (instance *RegexHelper) TagsBetweenStrings(text string, prefix, suffix string) []string

func (*RegexHelper) TagsBetweenTrimStrings

func (instance *RegexHelper) TagsBetweenTrimStrings(text string, prefix, suffix string) []string

func (*RegexHelper) TextBetweenBraces

func (instance *RegexHelper) TextBetweenBraces(text string) []string

func (*RegexHelper) TextBetweenStrings

func (instance *RegexHelper) TextBetweenStrings(text string, prefix string, suffix interface{}) []string

func (*RegexHelper) Time

func (instance *RegexHelper) Time(text string) []string

Time finds all time strings

func (*RegexHelper) Urls

func (instance *RegexHelper) Urls(text string) []string

Urls finds all URL strings

func (*RegexHelper) VISACreditCards

func (instance *RegexHelper) VISACreditCards(text string) []string

VISACreditCards finds all VISA credit card numbers

func (*RegexHelper) WildcardIndex

func (instance *RegexHelper) WildcardIndex(text string, pattern string, offset int) []int

WildcardIndex Return index array of matching expression in a text starting search from offset position @param text string. "hello humanity!!" @param pattern string "hu?an*" @param offset int number of characters to exclude from search @return []int

func (*RegexHelper) WildcardIndexArray

func (instance *RegexHelper) WildcardIndexArray(text string, patterns []string, offset int) [][]int

WildcardIndexArray works like WildcardIndex but cycle on an array of pattern elements

func (*RegexHelper) WildcardIndexLenPair

func (instance *RegexHelper) WildcardIndexLenPair(text string, pattern string, offset int) [][]int

WildcardIndexLenPair Return array of pair index:word_len of matching expression in a text @param text string. "hello humanity!!" @param pattern string "hu?an*" @return [][]int ex: [[12,3], [22,4]]

func (*RegexHelper) WildcardMatch

func (instance *RegexHelper) WildcardMatch(text, expression string) []string

func (*RegexHelper) WildcardMatchAll

func (instance *RegexHelper) WildcardMatchAll(text, expression string) ([]string, [][]int)

func (*RegexHelper) WildcardMatchBetween

func (instance *RegexHelper) WildcardMatchBetween(text string, offset int, patternStart string, patternEnd string, cutset string) []string

func (*RegexHelper) WildcardMatchIndex

func (instance *RegexHelper) WildcardMatchIndex(text, expression string) [][]int

func (*RegexHelper) WildcardScoreAll

func (instance *RegexHelper) WildcardScoreAll(phrase string, expressions []string) float32

WildcardScoreAll Calculate a matching score between a phrase and a check test using expressions. ALL expressions are evaluated. Failed expressions add negative score to result @param [string] phrase. "hello humanity!! I'm Mario rossi" @param [string] expressions. All expressions to match. ["hel??0 h*", "I* * ros*"]

Supported expressions:
	["hel??0 h*", "I* * ros*"]
	["hel??0 h*:1:1", "I* * ros*:1:0"]

func (*RegexHelper) WildcardScoreAny

func (instance *RegexHelper) WildcardScoreAny(phrase string, expressions []string) float32

WildcardScoreAny Calculate a matching score between a phrase and a check test using expressions. ALL expressions are evaluated. Failed expressions do not add negative score to result @param [string] phrase. "hello humanity!! I'm Mario rossi" @param [string] expressions. All expressions to match. ["hel??0 h*", "I* * ros*"]

func (*RegexHelper) WildcardScoreBest

func (instance *RegexHelper) WildcardScoreBest(phrase string, expressions []string) float32

WildcardScoreBest Calculate a matching score between a phrase and a check test using expressions. ALL expressions are evaluated. Failed expressions do not add negative score to result. Return best score above all @param [string] phrase. "hello humanity!! I'm Mario rossi" @param [string] expressions. All expressions to match. ["hel??0 h*", "I* * ros*"]

func (*RegexHelper) ZipCodes

func (instance *RegexHelper) ZipCodes(text string) []string

ZipCodes finds all zip codes

type StringsHelper

type StringsHelper struct {
}
var Strings *StringsHelper

func (*StringsHelper) CamelCase

func (instance *StringsHelper) CamelCase(inputUnderScoreStr string) (response string)

func (*StringsHelper) CapitalizeAll

func (instance *StringsHelper) CapitalizeAll(text string) string

func (*StringsHelper) CapitalizeFirst

func (instance *StringsHelper) CapitalizeFirst(text string) string

func (*StringsHelper) Clear

func (instance *StringsHelper) Clear(text string) string

func (*StringsHelper) Concat

func (instance *StringsHelper) Concat(params ...interface{}) string

func (*StringsHelper) ConcatSep

func (instance *StringsHelper) ConcatSep(separator string, params ...interface{}) string

func (*StringsHelper) ConcatTrimSep

func (instance *StringsHelper) ConcatTrimSep(separator string, params ...interface{}) string

func (*StringsHelper) Contains

func (instance *StringsHelper) Contains(s string, seps string) bool

func (*StringsHelper) FillLeft

func (instance *StringsHelper) FillLeft(text string, l int, r rune) string

func (*StringsHelper) FillLeftBytes

func (instance *StringsHelper) FillLeftBytes(bytes []byte, l int, r rune) []byte

func (*StringsHelper) FillLeftBytesZero

func (instance *StringsHelper) FillLeftBytesZero(bytes []byte, l int) []byte

func (*StringsHelper) FillLeftZero

func (instance *StringsHelper) FillLeftZero(text string, l int) string

func (*StringsHelper) FillRight

func (instance *StringsHelper) FillRight(text string, l int, r rune) string

func (*StringsHelper) FillRightBytes

func (instance *StringsHelper) FillRightBytes(bytes []byte, l int, r rune) []byte

func (*StringsHelper) FillRightBytesZero

func (instance *StringsHelper) FillRightBytesZero(bytes []byte, l int) []byte

func (*StringsHelper) FillRightZero

func (instance *StringsHelper) FillRightZero(text string, l int) string

func (*StringsHelper) Format

func (instance *StringsHelper) Format(s string, params ...interface{}) string

func (*StringsHelper) FormatValues

func (instance *StringsHelper) FormatValues(s string, params ...interface{}) string

func (*StringsHelper) IndexStartEnd

func (instance *StringsHelper) IndexStartEnd(s string, prefix, suffix string) (start, end int)

func (*StringsHelper) Paginate

func (instance *StringsHelper) Paginate(text string) string

Paginate Clear and paginate text on multiple rows. New rows only if prev char is a dot (.)

func (*StringsHelper) Quote

func (instance *StringsHelper) Quote(v interface{}) string

func (*StringsHelper) RemoveDuplicateSpaces

func (instance *StringsHelper) RemoveDuplicateSpaces(text string) string

func (*StringsHelper) Repeat

func (instance *StringsHelper) Repeat(s string, count int) string

func (*StringsHelper) Slugify

func (instance *StringsHelper) Slugify(text string, replaces ...string) string

func (*StringsHelper) SlugifyPath added in v0.2.52

func (instance *StringsHelper) SlugifyPath(text string) string

func (*StringsHelper) SnakeCase

func (instance *StringsHelper) SnakeCase(str string) string

func (*StringsHelper) SnakeCaseReplaceAll

func (instance *StringsHelper) SnakeCaseReplaceAll(str string, old string, new string) string

func (*StringsHelper) SnakeCaseTrim

func (instance *StringsHelper) SnakeCaseTrim(str string, cutset string) string

func (*StringsHelper) Split

func (instance *StringsHelper) Split(s string, seps string) []string

Split using all rune in a string of separators

func (*StringsHelper) SplitAfter

func (instance *StringsHelper) SplitAfter(s string, seps string) (tokens []string, separators []string)

func (*StringsHelper) SplitAndGetAt

func (instance *StringsHelper) SplitAndGetAt(s string, seps string, index int) string

func (*StringsHelper) SplitFirst

func (instance *StringsHelper) SplitFirst(s string, sep rune) []string

func (*StringsHelper) SplitLast

func (instance *StringsHelper) SplitLast(s string, sep rune) []string

func (*StringsHelper) SplitQuoted

func (instance *StringsHelper) SplitQuoted(s string, sep rune, quote rune) []string

SplitQuoted splits a string, ignoring separators present inside quoted runs. Separators cannot be escaped outside quoted runs, the escaping will be ignored.

Quotes are preserved in result, but the separators are removed.

func (*StringsHelper) SplitTrim

func (instance *StringsHelper) SplitTrim(s string, seps string, cutset string) []string

func (*StringsHelper) SplitTrimSpace

func (instance *StringsHelper) SplitTrimSpace(s string, seps string) []string

func (*StringsHelper) StripNotAlphaChar added in v0.2.52

func (instance *StringsHelper) StripNotAlphaChar(s string) string

func (*StringsHelper) Sub

func (instance *StringsHelper) Sub(s string, start int, end int) string

Sub get a substring @param s string The string @param start int Start index @param end int End index

func (*StringsHelper) SubBetween

func (instance *StringsHelper) SubBetween(s string, prefix, suffix string) string

func (*StringsHelper) Trim

func (instance *StringsHelper) Trim(slice []string, trimVal string)

func (*StringsHelper) TrimSpaces

func (instance *StringsHelper) TrimSpaces(slice []string)

func (*StringsHelper) Underscore

func (instance *StringsHelper) Underscore(s string) string

Underscore from "ThisIsAName" to "this_is_a_name". used to format json field names

func (*StringsHelper) Unquote

func (instance *StringsHelper) Unquote(v interface{}) (string, error)

type Workspace

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

func (*Workspace) GetPath

func (instance *Workspace) GetPath() string

func (*Workspace) IsChanged added in v0.2.20

func (instance *Workspace) IsChanged() bool

func (*Workspace) Resolve

func (instance *Workspace) Resolve(partial string) string

Resolve get an absolute path under this workspace path

func (*Workspace) SetPath

func (instance *Workspace) SetPath(path string)

type WorkspaceController

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

func NewWorkspaceController

func NewWorkspaceController() *WorkspaceController

func (*WorkspaceController) Get

func (instance *WorkspaceController) Get(name ...string) *Workspace

type XMLHelper

type XMLHelper struct {
}
var XML *XMLHelper

func (*XMLHelper) Read

func (instance *XMLHelper) Read(input interface{}, entity interface{}) (err error)

func (*XMLHelper) ReadFromFile

func (instance *XMLHelper) ReadFromFile(fileName string, entity interface{}) error

func (*XMLHelper) Stringify

func (instance *XMLHelper) Stringify(entity interface{}) string

type ZipHelper

type ZipHelper struct {
}
var Zip *ZipHelper

func (*ZipHelper) AddFileToZip

func (instance *ZipHelper) AddFileToZip(zipWriter *zip.Writer, filename string) error

func (*ZipHelper) GUnzip added in v0.2.37

func (instance *ZipHelper) GUnzip(data []byte) (response []byte, err error)

func (*ZipHelper) GZip added in v0.2.37

func (instance *ZipHelper) GZip(data []byte) (response []byte, err error)

func (*ZipHelper) Unzip

func (instance *ZipHelper) Unzip(src string, dest string) ([]string, error)

func (*ZipHelper) ZipFiles

func (instance *ZipHelper) ZipFiles(filename string, files []string) error

ZipFiles compresses one or many files into a single zip archive file. Param 1: filename is the output zip file's name. Param 2: files is a list of files to add to the zip.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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