Documentation ¶
Index ¶
- Constants
- func AvatarLink(email string) (url string)
- func BasicAuthDecode(encoded string) (string, string, error)
- func BasicAuthEncode(username, password string) string
- func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string
- func DetectEncoding(content []byte) (string, error)
- func EllipsisString(str string, length int) string
- func FileSize(s int64) string
- func HashEmail(email string) string
- func Int64sToMap(ints []int64) map[int64]bool
- func Int64sToStrings(ints []int64) []string
- func IsImageFile(data []byte) bool
- func IsLetter(ch rune) bool
- func IsPDFFile(data []byte) bool
- func IsTextFile(data []byte) bool
- func IsVideoFile(data []byte) bool
- func MD5(str string) string
- func MD5Bytes(str string) []byte
- func RandomString(n int) (string, error)
- func RawTimeSince(t time.Time, lang string) string
- func SHA1(str string) string
- func ShortSHA1(sha1 string) string
- func StringsToInt64s(strs []string) []int64
- func Subtract(left interface{}, right interface{}) interface{}
- func TimeSince(t time.Time, lang string) template.HTML
- func TimeSincePro(then time.Time) string
- func TruncateString(str string, limit int) string
- func VerifyTimeLimitCode(data string, minutes int, code string) bool
Constants ¶
const ( Byte = 1 KByte = Byte * 1024 MByte = KByte * 1024 GByte = MByte * 1024 TByte = GByte * 1024 PByte = TByte * 1024 EByte = PByte * 1024 )
const ( Minute = 60 Hour = 60 * Minute Day = 24 * Hour Week = 7 * Day Month = 30 * Day Year = 12 * Month )
Seconds-based time units
const TIME_LIMIT_CODE_LENGTH = 12 + 6 + 40
Variables ¶
This section is empty.
Functions ¶
func AvatarLink ¶
AvatarLink returns relative avatar link to the site domain by given email, which includes app sub-url as prefix. However, it is possible to return full URL if user enables Gravatar-like service.
func BasicAuthDecode ¶
BasicAuthDecode decodes username and password portions of HTTP Basic Authentication from encoded content.
func BasicAuthEncode ¶
BasicAuthEncode encodes username and password in HTTP Basic Authentication format.
func CreateTimeLimitCode ¶
CreateTimeLimitCode generates a time limit code based on given input data. Format: 12 length date time string + 6 minutes string + 40 sha1 encoded string
func DetectEncoding ¶
DetectEncoding returns best guess of encoding of given content.
func EllipsisString ¶
EllipsisString returns a truncated short string, it appends '...' in the end of the length of string is too large.
func HashEmail ¶
HashEmail hashes email address to MD5 string. https://en.gravatar.com/site/implement/hash/
func Int64sToMap ¶
Int64sToMap converts a slice of int64 to a int64 map.
func Int64sToStrings ¶
Int64sToStrings converts a slice of int64 to a slice of string.
func IsImageFile ¶
func IsLetter ¶
IsLetter reports whether the rune is a letter (category L). https://github.com/golang/go/blob/master/src/go/scanner/scanner.go#L257
func IsTextFile ¶
IsTextFile returns true if file content format is plain text or empty.
func IsVideoFile ¶
func RandomString ¶ added in v0.11.19
RandomString returns generated random string in given length of characters. It also returns possible error during generation.
func StringsToInt64s ¶
StringsToInt64s converts a slice of string to a slice of int64.
func Subtract ¶
func Subtract(left interface{}, right interface{}) interface{}
Subtract deals with subtraction of all types of number.
func TimeSincePro ¶
TimeSincePro calculates the time interval and generate full user-friendly string.
func TruncateString ¶
TruncateString returns a truncated string with given limit, it returns input string if length is not reached limit.
Types ¶
This section is empty.