Documentation ¶
Index ¶
- Constants
- func AddPropToJSONString(s, key string, prop interface{}) (string, error)
- func Decrypt(ciphertext string, key []byte) (string, error)
- func DecryptJSON(ciphertext, pass string, v interface{}) error
- func Encrypt(plaintext string, key []byte) (string, error)
- func EncryptJSON(v interface{}, pass string) (string, error)
- func GoAndRespawn(f func(), maxPanics int, onDone func(isFailed bool))
- func In(slice interface{}, val interface{}) bool
- func IndexOf(slice interface{}, val interface{}) int
- func MapStrings(arr []string, mapFunc func(int, string) string) []string
- func MarshalWithFilter(v interface{}, filters ...string) ([]byte, error)
- func Max(a int, b int) int
- func Min(a int, b int) int
- func RandStr(strSize int) string
- func SecureRandomString(size int, alphaOnly bool) string
- func SortString(arr []string)
- func SplitAndTrim(s string) []string
- func SplitOrEmpty(val string) (split []string)
- func ToGenericFilter(v interface{}, filters ...string) (interface{}, error)
- func ToIntf(s interface{}) []interface{}
- func ToLower(s []string) []string
Constants ¶
const ( // RecoverRoutineForever - this const is used to be passed to RunInSelfRecoverableGoRoutine // as maxPanics argument. It indicates that the RunInSelfRecoverableGoRoutine // will recover forever from panics RecoverRoutineForever = -1 )
Variables ¶
This section is empty.
Functions ¶
func AddPropToJSONString ¶
AddPropToJSONString receives the JSON string, key in the form of "part1.part2" and value and adds all the relevant parts to resulting JSON string For example, passing empty string and "Security.SessionKey" as key will create {"Security": {"SessionKey": val}} Does not support array values
func DecryptJSON ¶
DecryptJSON decrypts to object
func EncryptJSON ¶
EncryptJSON encrypts the given object by serializing to JSON and using Encrypt
func GoAndRespawn ¶
GoAndRespawn - the function runs the f function as a go routine. If f panics, it will recover from the panic and re-run the function. If f finished without panic, then the go routine will finish. maxPanics - if f() paniced maxPanics times, then the routine will be stopped.
Use RecoverRoutineForever const to recover forever from panics
onDone - is a callback which executed when or f() finished gracefully or maxPanics occured.
It passes isFailed which indicates if f() finished gracefully or opaniced maxPanics times
func IndexOf ¶
func IndexOf(slice interface{}, val interface{}) int
IndexOf returns the index of an object in an array based on obj1 == obj2
func MapStrings ¶
MapStrings with a translate function (like Array.map in JS)
func MarshalWithFilter ¶
MarshalWithFilter the given struct while filtering out the given Fields The filters should be in the form of x.y where x and y are the JSON names (as in the JSON tags) Naive and slow implementation - might be rewritten if needed
func SecureRandomString ¶
SecureRandomString generate a secure random string of size that can be alpha or alphanum
func SplitAndTrim ¶
SplitAndTrim , split by token "," and trim rach result
func SplitOrEmpty ¶
SplitOrEmpty returns the value split by "," or empty array if val is empty
func ToGenericFilter ¶
ToGenericFilter translates an object to generic slices and maps while filtering the given fields
Types ¶
This section is empty.