utils

package
v0.0.0-...-1fbbad1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2016 License: GPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Regex_Email        string = "[\\w!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[a-zA-Z0-9](?:[\\w-]*[\\w])?"
	Regex_Numeric      string = "^[-+]?[0-9]+$"
	Regex_Alpha        string = "^[a-zA-Z]+$"
	Regex_AlphaNumeric string = "^[a-zA-Z0-9]+$"
	Regex_Int          string = "^(?:[-+]?(?:0|[1-9][0-9]*))$"
	Regex_Float        string = "^(?:[-+]?(?:[0-9]+))?(?:\\.[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"
	Regex_DataURI      string = "^data:.+\\/(.+);base64$"
	Regex_URL          string = `` /* 301-byte string literal not displayed */
	Regex_Base64       string = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$"
)

Variables

This section is empty.

Functions

func EncodeMd5

func EncodeMd5(str string) string

Encode string to md5 hex value.

func EncodeSha1

func EncodeSha1(str string) string

Encode string to sha1 hex value.

func GetRandomString

func GetRandomString(n int, alphabets ...byte) string

GetRandomString generate random string by specify chars.

func IsAlpha

func IsAlpha(str string) bool

IsAlpha check if the string contains only letters (a-zA-Z). Empty string is valid.

func IsAlphaNumeric

func IsAlphaNumeric(str string) bool

IsAlphanumeric check if the string contains only letters and numbers. Empty string is invalid.

func IsBase64

func IsBase64(str string) bool

IsBase64 check if a string is base64 encoded.

func IsDataURI

func IsDataURI(str string) bool

IsDataURI checks if a string is base64 encoded data URI such as an image

func IsEmail

func IsEmail(data string) bool

IsEmail check email address

func IsEmpty

func IsEmpty(data string) bool

IsEmpty check if the string is empty.

func IsFile

func IsFile(filePath string) bool

IsFile returns true if given path is a file, or returns false when it's a directory or does not exist.

func IsFloat

func IsFloat(str string) bool

IsFloat check if the string is a float. Empty string is invalid.

func IsInt

func IsInt(str string) bool

IsInt check if the string is an integer. Empty string is invalid.

func IsNumeric

func IsNumeric(data string) bool

IsNumber returns whether the given data is a number

func IsURL

func IsURL(data string) bool

IsURL check if the string is an URL.

func PBKDF2

func PBKDF2(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte

http://code.google.com/p/go/source/browse/pbkdf2/pbkdf2.go?repo=crypto

func StringInSlice

func StringInSlice(str string, list []string) bool

StringInSlice check if given string in list

func StripTagsFromHtml

func StripTagsFromHtml(input string) string

func SubString

func SubString(str string, length int) string

func ToBool

func ToBool(val interface{}) bool

ToBool try to convert the argument into a bool

func ToFloat64

func ToFloat64(val interface{}) float64

ToFloat64 try to convert the argument into a float64

func ToInt

func ToInt(val interface{}) int

ToInt try to convert the argument into a int

func ToInt64

func ToInt64(val interface{}) int64

ToInt64 try to convert the argument into a int64

func ToString

func ToString(val interface{}) string

ToString try to convert the argument into a string

func ToTime

func ToTime(val interface{}) time.Time

ToTime try to convert the argument into a time

func ToUint32

func ToUint32(val interface{}) uint32

ToUint32 try to convert the argument into a uint32

func ToUint64

func ToUint64(val interface{}) uint64

ToUint64 try to convert the argument into a uint64

Types

This section is empty.

Directories

Path Synopsis
https://github.com/martini-contrib/acceptlang
https://github.com/martini-contrib/acceptlang
Package uuid provides implementation of Universally Unique Identifier (UUID).
Package uuid provides implementation of Universally Unique Identifier (UUID).

Jump to

Keyboard shortcuts

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