{"modulePath":"github.com/generaltso/gitea","version":"v1.2.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package base\n\n## Constants\n\n```go\nconst (\n\tMinute = 60\n\tHour   = 60 * Minute\n\tDay    = 24 * Hour\n\tWeek   = 7 * Day\n\tMonth  = 30 * Day\n\tYear   = 12 * Month\n)\n```\nSeconds-based time units\n\n```go\nconst (\n\tByte  = 1\n\tKByte = Byte * 1024\n\tMByte = KByte * 1024\n\tGByte = MByte * 1024\n\tTByte = GByte * 1024\n\tPByte = TByte * 1024\n\tEByte = PByte * 1024\n)\n```\nStorage space size types\n\n```go\nconst DocURL = \"https://godoc.org/github.com/go-gitea/go-sdk/gitea\"\n```\nDocURL api doc url\n\n```go\nconst TimeLimitCodeLength = 12 + 6 + 40\n```\nTimeLimitCodeLength default value for time limit code\n\n## Functions\n\n```go\nfunc AvatarLink(email string) string\n```\nAvatarLink 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.\n\n```go\nfunc BasicAuthDecode(encoded string) (string, string, error)\n```\nBasicAuthDecode decode basic auth string\n\n```go\nfunc BasicAuthEncode(username, password string) string\n```\nBasicAuthEncode encode basic auth string\n\n```go\nfunc CreateTimeLimitCode(data string, minutes int, startInf interface{}) string\n```\nCreateTimeLimitCode create a time limit code code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string\n\n```go\nfunc DefaultAvatarLink() string\n```\nDefaultAvatarLink the default avatar link\n\n```go\nfunc DetectEncoding(content []byte) (string, error)\n```\nDetectEncoding detect the encoding of content\n\n```go\nfunc EllipsisString(str string, length int) string\n```\nEllipsisString returns a truncated short string, it appends '...' in the end of the length of string is too large.\n\n```go\nfunc EncodeMD5(str string) string\n```\nEncodeMD5 encodes string to md5 hex value.\n\n```go\nfunc EncodeSha1(str string) string\n```\nEncodeSha1 string to sha1 hex value.\n\n```go\nfunc FileSize(s int64) string\n```\nFileSize calculates the file size and generate user-friendly string.\n\n```go\nfunc GetRandomBytesAsBase64(n int) string\n```\nGetRandomBytesAsBase64 generates a random base64 string from n bytes\n\n```go\nfunc GetRandomString(n int) (string, error)\n```\nGetRandomString generate random string by specify chars.\n\n```go\nfunc HashEmail(email string) string\n```\nHashEmail hashes email address to MD5 string. [https://en.gravatar.com/site/implement/hash/](https://en.gravatar.com/site/implement/hash/)\n\n```go\nfunc Int64sToMap(ints []int64) map[int64]bool\n```\nInt64sToMap converts a slice of int64 to a int64 map.\n\n```go\nfunc Int64sToStrings(ints []int64) []string\n```\nInt64sToStrings converts a slice of int64 to a slice of string.\n\n```go\nfunc IsImageFile(data []byte) bool\n```\nIsImageFile detects if data is an image format\n\n```go\nfunc IsLetter(ch rune) bool\n```\nIsLetter reports whether the rune is a letter (category L). [https://github.com/golang/go/blob/master/src/go/scanner/scanner.go#L257](https://github.com/golang/go/blob/master/src/go/scanner/scanner.go#L257)\n\n```go\nfunc IsPDFFile(data []byte) bool\n```\nIsPDFFile detects if data is a pdf format\n\n```go\nfunc IsTextFile(data []byte) bool\n```\nIsTextFile returns true if file content format is plain text or empty.\n\n```go\nfunc IsVideoFile(data []byte) bool\n```\nIsVideoFile detects if data is an video format\n\n```go\nfunc MinutesToFriendly(minutes int, lang string) string\n```\nMinutesToFriendly returns a user friendly string with number of minutes converted to hours and minutes.\n\n```go\nfunc RawTimeSince(t time.Time, lang string) string\n```\nRawTimeSince retrieves i18n key of time since t\n\n```go\nfunc ShortSha(sha1 string) string\n```\nShortSha is basically just truncating. It is DEPRECATED and will be removed in the future.\n\n```go\nfunc StringsToInt64s(strs []string) ([]int64, error)\n```\nStringsToInt64s converts a slice of string to a slice of int64.\n\n```go\nfunc Subtract(left interface{}, right interface{}) interface{}\n```\nSubtract deals with subtraction of all types of number.\n\n```go\nfunc TimeSince(then time.Time, lang string) template.HTML\n```\nTimeSince calculates the time interval and generate user-friendly string.\n\n```go\nfunc TimeSincePro(then time.Time, lang string) string\n```\nTimeSincePro calculates the time interval and generate full user-friendly string.\n\n```go\nfunc TruncateString(str string, limit int) string\n```\nTruncateString returns a truncated string with given limit, it returns input string if length is not reached limit.\n\n```go\nfunc VerifyTimeLimitCode(data string, minutes int, code string) bool\n```\nVerifyTimeLimitCode verify time limit code\n\n## Types\n\n```go\ntype TplName string\n```\nTplName template relative path type\n\n","path":"github.com/generaltso/gitea/modules/base","name":"base","synopsis":"","isRedistributable":true}
