Documentation ¶
Index ¶
- Constants
- Variables
- func Assert(cond bool, msg string, fatal bool) bool
- func BcryptCheckPasswordHash(password, hash string) bool
- func BcryptHashPassword(password string, cost int) (string, error)
- func CheckErr(err error, location string)
- func CheckErrNonFatal(err error, location string) error
- func CheckNonErrIfMatch(err error, ptn, location string) error
- func ChunkString(s string, chunkSize int) []string
- func ComputeHash(plainText string, salt []byte) string
- func ConfigureLogging(w *os.File)
- func Curl(method, url, data, savefilename string, headers []string) (string, error)
- func Decrypt(ciphertextBase64 string, key string) (string, error)
- func Encrypt(text, key string) string
- func FileExists(name string) (bool, error)
- func FileNameWithoutExtension(fileName string) string
- func FileTouch(fileName string) error
- func FindAndParseTemplates(rootDir, fileExtention string, funcMap template.FuncMap) (*template.Template, []string, error)
- func Format(tmplStr string, data interface{}) string
- func GenRandomString(n int) string
- func GenRandomStringV2(n int) string
- func GenSelfSignedKey(keyfilename string)
- func GetFormValue(r *http.Request, key ...string) string
- func GetMuxValue(r *http.Request, key ...string) string
- func GetQueryValue(r *http.Request, key ...string) string
- func GetRandomNumberUseQrng(length int) []int
- func GetRequestValue(r *http.Request, key ...string) string
- func Getenv(key, fallback string) string
- func JsonDump(obj interface{}, indent string) string
- func JsonDumpByte(obj interface{}, indent string) []byte
- func LoadConfigIntoEnv(configFile string) map[string]interface{}
- func LookupMap(m map[string]interface{}, key string, default_val interface{}) interface{}
- func MakePassword(length int) string
- func MakeRandNum(max int) int
- func MakeRequest(method string, config map[string]interface{}, data []byte, jar *cookiejar.Jar) map[string]interface{}
- func MakeSalt(length int8) (salt *[]byte)
- func Md5Sum(key string) string
- func MergeAttributes(a, b []interface{}, action string) []interface{}
- func MustOpenFile(f string) *os.File
- func NsToTime(ns int64) time.Time
- func ParseConfig(configFile string) map[string]interface{}
- func ParseTimeRange(durationStr, tz string) (time.Time, time.Time)
- func RandomHex(n int) (string, error)
- func ReadFileToBase64Content(filename string) string
- func RemoveDuplicate(strSlice []interface{}) []interface{}
- func RemoveDuplicateInt(strSlice []int) []int
- func RemoveDuplicateStr(strSlice []string) []string
- func RemoveItem(s []interface{}, i int) []interface{}
- func RunDSL(dbc *sql.DB, sql string) map[string]interface{}
- func RunSQL(dbc *sql.DB, sql string) map[string]interface{}
- func RunSystemCommand(cmd string, verbose bool) string
- func RunSystemCommandV2(cmd string, verbose bool) (string, error)
- func SendMail(from string, to []string, subject string, message string, attachments []string, ...) error
- func SendMailSendGrid(from, to, subject, plainTextContent, htmlContent string, attachments []string) error
- func Sha1Sum(in string) string
- func Sha256Sum(in string) string
- func Sha512Sum(in string) string
- func Sleep(duration string)
- func Ternary(expr bool, x, y interface{}) interface{}
- func Unzip(src, dest string) error
- func Upload(client *http.Client, url string, values map[string]io.Reader, ...) (err error)
- func ValidateInterfaceWithStringKeys(val interface{}) (interface{}, error)
- func VerifyHash(password string, passwordHashString string, saltLength int) bool
- func ZipDecrypt(filePath ...string) error
- func ZipEncript(filePath ...string) string
- type AppConfigProperties
Constants ¶
const ( TimeISO8601LayOut = "2006-01-02T15:04:05-0700" AUTimeLayout = "02/01/2006 15:04:05 MST" CleanStringDateLayout = "2006-01-02-150405" LetterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#%^()-,." )
TimeISO8601LayOut
Variables ¶
var GetMapByKey = LookupMap
GetMapByKey - we have LookupMap
var MapLookup = LookupMap
Functions ¶
func BcryptCheckPasswordHash ¶
func CheckErrNonFatal ¶
func CheckNonErrIfMatch ¶
func ComputeHash ¶
func ConfigureLogging ¶
func FileExists ¶
func FindAndParseTemplates ¶
func GenRandomString ¶
func GenRandomStringV2 ¶
func GenSelfSignedKey ¶
func GenSelfSignedKey(keyfilename string)
func GetRandomNumberUseQrng ¶
OK seems ANU is too scared of abuse, even using with api key it still limit reqeust severely. Offer no so much value unless we need to buy? Yuk!
func GetRequestValue ¶
GetRequestValue - Attempt to get a val by key from the request in all cases. First from the mux variables in the route path such as /dosomething/{var1}/{var2} Then check the query string values such as /dosomething?var1=x&var2=y Then check the form values if any Then check the default value if supplied to use as return value For performance we split each type into each function so it can be called independantly
func JsonDumpByte ¶
func LoadConfigIntoEnv ¶
func MakeRequest ¶
func MergeAttributes ¶
func MergeAttributes(a, b []interface{}, action string) []interface{}
Add or delete attrbs set in a to b
func MustOpenFile ¶
func ParseConfig ¶
func ParseTimeRange ¶
Given a duration string return a tuple of start time, end time satisfy the duration. If duration string is dd/mm/yyyy hh:mm:ss - dd/mm/yyyy hh:mm:ss it simply return two time object. If duration is like 15m then endtime is now, start time is 15 minutes ago. This applies for all case if input is not parsable
func ReadFileToBase64Content ¶
func RemoveDuplicate ¶
func RemoveDuplicate(strSlice []interface{}) []interface{}
func RemoveDuplicateInt ¶
func RemoveDuplicateStr ¶
func RemoveItem ¶
func RemoveItem(s []interface{}, i int) []interface{}
func RunSystemCommand ¶
func SendMailSendGrid ¶
func ValidateInterfaceWithStringKeys ¶
func ValidateInterfaceWithStringKeys(val interface{}) (interface{}, error)
Pass an interface, return same interface if they are string as key or list of string as key
func ZipDecrypt ¶
func ZipEncript ¶
Types ¶
type AppConfigProperties ¶
func ReadPropertiesFile ¶
func ReadPropertiesFile(filename string) (AppConfigProperties, error)
func ReadPropertiesString ¶
func ReadPropertiesString(inputString string) (AppConfigProperties, error)