Documentation
¶
Overview ¶
Package general - contains general functions
Index ¶
- Variables
- func AESCBCPKCS5Decryption(encryptedMessage, key string) (string, error)
- func AESCBCPKCS5Encryption(message, key string) (string, error)
- func AESDecrypt(b64src string, key string) string
- func AESEncrypt(src, key string) string
- func AmountInWords(amount float64) string
- func CalculateMedian(n []float64) float64
- func CheckSupportedFormats(r *http.Request, extensions, contentTypes []string) (multipart.File, string, int, string)
- func CheckWithinNDays(inputDateStr string, n int) bool
- func CleanAddressLine(addressLine string) string
- func CleanColumn(column string) string
- func ConvertTimeToTimestamp(time time.Time) int64
- func ConvertTimestampToTime(timestamp int64) time.Time
- func DateEqual(date1, date2 time.Time) bool
- func DeleteFileByPath(path string) error
- func DeprecatedValidateStruct(s interface{}) error
- func FileFromURLtoBase64(url string) string
- func FormatCurrency(amount float64, showDecimal bool) string
- func GenerateHashedKey(password, key string) []byte
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomNumber(n int) (string, error)
- func GenerateRandomString(n int) (string, error)
- func GetDifferenceInMonths(a, b time.Time) int
- func GetFilePathFromMultipart(file multipart.File) (string, error)
- func GetFirstSurName(name string) (string, string)
- func GetInitial(word string) string
- func GetOnlyAlphaNumSpace(input string) string
- func GetOnlyAlphaNumUpper(input string) string
- func GetOnlyAlphaSpace(input string) string
- func GetStringFromTemplate(templateString string, data map[string]interface{}) string
- func GetTimeStampPair() (time.Time, string)
- func GetTimeStampString() string
- func GetUUID() string
- func IdentReader(encoding string, input io.Reader) (io.Reader, error)
- func InArrInt(val int, arr []int) bool
- func InArrStr(val string, arr []string) bool
- func IsAlphanumeric(input string) bool
- func IsFreeMail(email string) bool
- func IsInt(uidParam string) (int, error)
- func IsLeapYear(year int) bool
- func IsNumber(s string) bool
- func IsStringNumeric(inputStr string) bool
- func KeepOnlyAlphaSpace(text string) string
- func LogTimeDifference(startTime time.Time)
- func NewECBDecrypter(b cipher.Block) cipher.BlockMode
- func NewECBEncrypter(b cipher.Block) cipher.BlockMode
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) []byte
- func RemoveAllSpaces(input string) string
- func RemoveCountryCode(mobile string) string
- func RemoveDuplicatesAndEmpty(s []string) []string
- func RemoveEmptyElements(s []string) []string
- func RemoveExtraSpaces(input string) string
- func RemoveNonUTF8Bytes(data []byte) []byte
- func RemoveNonUTF8Strings(string string) string
- func SQLInjectionValidation(val string) bool
- func StartTime() time.Time
- func TimeDifference(startTime time.Time) time.Duration
- func ToSnakeCase(str string) string
- func ValidateAccountNumber(accountNumber string) bool
- func ValidateEmail(email string) bool
- func ValidateGSTIN(gstin string) bool
- func ValidateIFSC(ifsc string) bool
- func ValidateName(name string) bool
- func ValidateNonPersonalPAN(pan string) bool
- func ValidatePAN(pan string) bool
- func ValidatePersonalPAN(pan string) bool
- func ValidatePincode(pincode string) bool
- func ValidateReferenceID(referenceID string) bool
- func ValidateURL(str string) bool
- func ValidateUUID(inputStr string) bool
Constants ¶
This section is empty.
Variables ¶
var ValidLanguageNameRegex = regexp.MustCompile("^[a-zA-Z ]{3,70}$")
Functions ¶
func AESCBCPKCS5Decryption ¶
func AESCBCPKCS5Encryption ¶
func AESDecrypt ¶
AESDecrypt does decryption of base64 encoded AES encrypted data an returns plain string
func AESEncrypt ¶
AESEncrypt does AES Encryption and return base64
func AmountInWords ¶
AmountInWords returns the amount in words
func CalculateMedian ¶
CalculateMedian returns median of numbers
func CheckSupportedFormats ¶
func CheckSupportedFormats(r *http.Request, extensions, contentTypes []string) (multipart.File, string, int, string)
CheckSupportedFormats checks for supported formats and returns file object, extension, error http code and error message if any
func CheckWithinNDays ¶
CheckWithinNDays takes input string in YYYY-MM-DD format
func CleanAddressLine ¶
CleanAddressLine removes unallowed characters from address
func CleanColumn ¶
CleanColumn removes unallowed characters from address
func ConvertTimeToTimestamp ¶
func ConvertTimestampToTime ¶
func DeleteFileByPath ¶
func DeprecatedValidateStruct ¶
func DeprecatedValidateStruct(s interface{}) error
ValidateStruct validates the struct and return error if they occur
func FileFromURLtoBase64 ¶
FileFromURLtoBase64 retrieves file using url and converts to base64
func FormatCurrency ¶
FormatCurrency returns a formatted string with commas for given amount
func GenerateHashedKey ¶
func GenerateRandomBytes ¶
GenerateRandomBytes generates and returns random bytes of specified size n
func GenerateRandomNumber ¶
func GenerateRandomString ¶
GenerateRandomString generates and returns a random alphanumeric string with a start_string (with mixed case) of size n
func GetDifferenceInMonths ¶
func GetFirstSurName ¶
GetFirstSurName returns first and last name
func GetInitial ¶
GetInitial returns two letter initials from a word
func GetOnlyAlphaNumSpace ¶
GetOnlyAlphaNumSpace removes everything except alpha numeric characters and space it also removes extra spaces, and keeps case intact
func GetOnlyAlphaNumUpper ¶
GetOnlyAlphaNumUpper removes everything except alpha numeric characters and turn to upper case
func GetOnlyAlphaSpace ¶
GetOnlyAlphaSpace removes everything except alpha characters and space it also removes extra spaces, and keeps case intact
func GetStringFromTemplate ¶
GetStringFromTemplate constructs a string by replacing placeholders using a map and returns it
func GetTimeStampPair ¶
GetTimeStampPair returns the current time object as well as YYYY-MM-DD HH:MM:SS.MMMMMM format
func GetTimeStampString ¶
func GetTimeStampString() string
GetTimeStampString returns the current time in YYYY-MM-DD HH:MM:SS.MMMMMM format
func IdentReader ¶
IdentReader is used while xml parsing
func IsAlphanumeric ¶
func IsFreeMail ¶
IsFreeMail checks whether a given email is from a free service or not
func IsLeapYear ¶
func IsStringNumeric ¶
IsStringNumeric returns if string contains only numbers
func KeepOnlyAlphaSpace ¶
KeepOnlyAlphaSpace removes everything except alphabets and space
func LogTimeDifference ¶
LogTimeDifference logs the elapsed time
func NewECBEncrypter ¶
NewECBEncrypter returns a BlockMode which encrypts in electronic code book mode, using the given Block.
func PKCS5Padding ¶
func PKCS5UnPadding ¶
func RemoveAllSpaces ¶
RemoveAllSpaces removes all spaces from a string
func RemoveCountryCode ¶
RemoveCountryCode removes the country code and spaces from input mobile string
func RemoveDuplicatesAndEmpty ¶
RemoveDuplicatesAndEmpty removes duplicate strings from list
func RemoveEmptyElements ¶
RemoveEmptyElements removes empty values from list
func RemoveExtraSpaces ¶
RemoveExtraSpaces removes excess spaces from a string
func RemoveNonUTF8Bytes ¶
RemoveNonUTF8Bytes removes bytes that isn't UTF-8 encoded
func RemoveNonUTF8Strings ¶
RemoveNonUTF8Strings removes strings that isn't UTF-8 encoded
func SQLInjectionValidation ¶
SQLInjectionValidation return bool if the username if valid, to prevent SQL injection
func TimeDifference ¶
TimeDifference returns elapsed time
func ToSnakeCase ¶
func ValidateAccountNumber ¶
ValidateAccountNumber checks for valid account number
func ValidateGSTIN ¶
ValidateGSTIN validates input capitalised string for being a valid GSTIN
func ValidateIFSC ¶
func ValidateName ¶
func ValidateNonPersonalPAN ¶
ValidateNonPersonalPAN validates input capitalised string for being a valid PAN
func ValidatePAN ¶
ValidatePAN validates input capitalised string for being a valid PAN
func ValidatePersonalPAN ¶
ValidatePersonalPAN validates input capitalised string for being a valid PAN and if its personal
func ValidatePincode ¶
ValidatePincode validates input string for being a valid pincode
func ValidateReferenceID ¶
func ValidateURL ¶
ValidateURL validates input string for being a valid URL
func ValidateUUID ¶
Types ¶
This section is empty.