base

package
v0.9.13 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2016 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Minute = 60
	Hour   = 60 * Minute
	Day    = 24 * Hour
	Week   = 7 * Day
	Month  = 30 * Day
	Year   = 12 * Month
)

Seconds-based time units

View Source
const (
	Byte  = 1
	KByte = Byte * 1024
	MByte = KByte * 1024
	GByte = MByte * 1024
	TByte = GByte * 1024
	PByte = TByte * 1024
	EByte = PByte * 1024
)
View Source
const DOC_URL = "https://github.com/gogits/go-gogs-client/wiki"
View Source
const TimeLimitCodeLength = 12 + 6 + 40

Variables

This section is empty.

Functions

func AvatarLink(email string) string

AvatarLink returns avatar link by given email.

func BasicAuthDecode added in v0.5.8

func BasicAuthDecode(encoded string) (string, string, error)

func BasicAuthEncode added in v0.5.8

func BasicAuthEncode(username, password string) string

func CreateTimeLimitCode

func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string

create a time limit code code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string

func DetectEncoding added in v0.5.9

func DetectEncoding(content []byte) (string, error)

func EllipsisString added in v0.8.25

func EllipsisString(str string, length int) string

EllipsisString returns a truncated short string, it appends '...' in the end of the length of string is too large.

func EncodeMD5 added in v0.7.22

func EncodeMD5(str string) string

EncodeMD5 encodes string to md5 hex value.

func EncodeSha1 added in v0.5.8

func EncodeSha1(str string) string

Encode string to sha1 hex value.

func FileSize

func FileSize(s int64) string

FileSize calculates the file size and generate user-friendly string.

func GetRandomString

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

GetRandomString generate random string by specify chars.

func HashEmail added in v0.8.43

func HashEmail(email string) string

HashEmail hashes email address to MD5 string. https://en.gravatar.com/site/implement/hash/

func Int64sToMap added in v0.6.5

func Int64sToMap(ints []int64) map[int64]bool

Int64sToMap converts a slice of int64 to a int64 map.

func Int64sToStrings added in v0.6.9

func Int64sToStrings(ints []int64) []string

Int64sToStrings converts a slice of int64 to a slice of string.

func IsImageFile

func IsImageFile(data []byte) (string, bool)

func IsLetter added in v0.8.43

func IsLetter(ch rune) bool

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

func IsTextFile(data []byte) (string, bool)

func PBKDF2 added in v0.3.0

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 FIXME: use https://godoc.org/golang.org/x/crypto/pbkdf2?

func RawTimeSince added in v0.6.5

func RawTimeSince(t time.Time, lang string) string

func ShortSha

func ShortSha(sha1 string) string

func StringsToInt64s added in v0.6.5

func StringsToInt64s(strs []string) []int64

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 TimeSince

func TimeSince(t time.Time, lang string) template.HTML

TimeSince calculates the time interval and generate user-friendly string.

func TimeSincePro

func TimeSincePro(then time.Time) string

TimeSincePro calculates the time interval and generate full user-friendly string.

func TruncateString added in v0.9.0

func TruncateString(str string, limit int) string

TruncateString returns a truncated string with given limit, it returns input string if length is not reached limit.

func VerifyTimeLimitCode

func VerifyTimeLimitCode(data string, minutes int, code string) bool

verify time limit code

Types

type TplName added in v0.5.0

type TplName string

Jump to

Keyboard shortcuts

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