Documentation
¶
Index ¶
- func CopyDir(source string, dest string) (err error)
- func CopyFile(source string, dest string) (err error)
- func DateFormat(t *time.Time, format string) string
- func FailOnError(err error, msg string, appendErr ...bool)
- func FileSize(size int64) string
- func Gravatar(email string, size string) string
- func Html2Excerpt(html string, length int) string
- func Html2Str(html string) string
- func IsASCII(str string) bool
- func IsContain(str string, contain string) bool
- func IsDir(path string) bool
- func IsEmail(str string) bool
- func IsEmptyString(str string) bool
- func IsEnglish(str string) bool
- func IsFile(path string) bool
- func IsLonger(str string, length int) bool
- func IsShorter(str string, length int) bool
- func IsURL(str string) bool
- func LogOnEither(err error, successMsg, errorMsg string, appendErr ...bool)
- func LogOnError(err error, msg string, appendErr ...bool)
- func LogOnSuccess(err error, msg string)
- func Markdown2Html(text string) string
- func Markdown2HtmlTemplate(text string) template.HTML
- func Now() *time.Time
- func Output(s string)
- func ReadMemStats() *monitorStats
- func Sha1(raw string) string
- func SubString(str string, begin, length int) (substr string)
- type Pager
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyDir ¶
CopyDir recursively copies a directory tree, attempting to preserve permissions. The source directory must exist, but destination directory must *not* exist.
func CopyFile ¶
CopyFile copies the source file to the destination file. If the destination file does not yet exist, it will create a new file there.
func DateFormat ¶
DateFormat implements formatted printing for time.Time values. It is similar to fmt's printf utility, although the verbs are different.
The verbs:
%B the full month, ex: "January" %b an abbreviation of the month, ex: "Jan" %m the month as a number, with the leading zero included, ex: "01" %A the full weekday, ex: "Monday" %a an abbreviation of the weekday, ex: "Mon" %d the day, with the leading zero included, ex: "31" %H the hour, in 24 hour time, with the leading zero included, ex: "15" %I the hour, in 12 hour time, with the leading zero included, ex: "08" %M the minute, with the leading zero included, ex: "42" %S the second, with the leading zero included, ex: "58" %Y the full year, ex: "2016" %y the last two digits of the year, ex: "16" %p the meridiem, or more simply put, AM or PM, ex: "AM" %Z letters representing the timezone, ex: "MST" %z numbers representing the timezone, ex: "-0700" %L milliseconds, ex: ".000"
Example ¶
t := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC) fmt.Println(DateFormat(&t, "%Y-%m-%d %H:%M"))
Output: 2009-11-10 23:00
func FailOnError ¶
func FileSize ¶
FileSize returns the file size as a string, formatted in the way people usually see filenames, ex: "1MB", "3KB", "60B".
func Gravatar ¶
Gravatar generates a Gravatar link with a given email and size. Images are always square, so we only accept a single argument for the size.
func Html2Excerpt ¶
Html2Excerpt returns the string from the given HTML that is "length" long.
func Html2Str ¶
Html2Str converts the given HTML to a string, removing all HTML tags, scripts, and styles, and removing continuous newline characters.
func IsEmptyString ¶
IsEmptyString returns whether or not a string is empty.
func IsEnglish ¶
IsEnglish returns whether or not the string is in English by looking at the character set.
func LogOnEither ¶
func LogOnError ¶
func LogOnSuccess ¶
func Markdown2Html ¶
Markdown2Html returns the given text as Markdown, using BlackFriday as a markdown compiler.
func Markdown2HtmlTemplate ¶
Markdown2HtmlTemplate returns the given text as Markdown, as the template package's HTML type.
func ReadMemStats ¶
func ReadMemStats() *monitorStats
ReadMemStats reads and returns various stats from the runtime. Used for displaying runtime info is the admin dashboard.