{"modulePath":"github.com/stackdocker/gogs","version":"v0.9.13","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```\n\n```go\nconst DOC_URL = \"https://github.com/gogits/go-gogs-client/wiki\"\n```\n\n```go\nconst TimeLimitCodeLength = 12 + 6 + 40\n```\n\n## Functions\n\n```go\nfunc AvatarLink(email string) string\n```\nAvatarLink returns avatar link by given email.\n\n```go\nfunc BasicAuthDecode(encoded string) (string, string, error)\n```\n\n```go\nfunc BasicAuthEncode(username, password string) string\n```\n\n```go\nfunc CreateTimeLimitCode(data string, minutes int, startInf interface{}) string\n```\ncreate a time limit code code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string\n\n```go\nfunc DetectEncoding(content []byte) (string, error)\n```\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```\nEncode 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 GetRandomString(n int, alphabets ...byte) string\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) (string, bool)\n```\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 IsTextFile(data []byte) (string, bool)\n```\n\n```go\nfunc PBKDF2(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte\n```\n[http://code.google.com/p/go/source/browse/pbkdf2/pbkdf2.go?repo=crypto](http://code.google.com/p/go/source/browse/pbkdf2/pbkdf2.go?repo=crypto) FIXME: use [https://godoc.org/golang.org/x/crypto/pbkdf2](https://godoc.org/golang.org/x/crypto/pbkdf2)?\n\n```go\nfunc RawTimeSince(t time.Time, lang string) string\n```\n\n```go\nfunc ShortSha(sha1 string) string\n```\n\n```go\nfunc StringsToInt64s(strs []string) []int64\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(t 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) 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```\nverify time limit code\n\n## Types\n\n```go\ntype TplName string\n```\n\n","path":"github.com/stackdocker/gogs/modules/base","name":"base","synopsis":"","isRedistributable":true}
