Documentation ¶
Index ¶
- func AppendStr(strs []string, str string) []string
- func GetJSON(url string, resp interface{}) error
- func IsSliceContainsStr(sl []string, str string) bool
- func Pluralize(count int, word string) string
- func PluralizeWord(count int, word string) string
- func PostJSON(url string, data, resp interface{}) error
- func PrettifyNumber(num int) string
- func PrettifySuffix(num int) string
- func RawPrettifySuffix(num, blockSize float64, suffixes []string) string
- func RenderRespond(r func(format string, v ...interface{}) error, logger *logrus.Entry, ...) bool
- func RenderTemplate(t *template.Template, vars interface{}) (string, error)
- func TemplateMustCompile(name, data string) *template.Template
- type ContextKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSliceContainsStr ¶
IsSliceContainsStr returns true if the string exists in given slice, ignore case.
func Pluralize ¶
Pluralize attempts to pluralize the given word (and display the number) if count > 1
func PluralizeWord ¶
PluralizeWord attempts to pluralize the given word if count > 1
func PrettifyNumber ¶
PrettifyNumber displays a number with commas
func PrettifySuffix ¶
PrettifySuffix displays a semi-human-readable format such as 4k in place of 4125.
func RawPrettifySuffix ¶
RawPrettifySuffix displays a semi-human-readable format such as 4k in place of 4125 with a number of weird options.
func RenderRespond ¶
func RenderRespond(r func(format string, v ...interface{}) error, logger *logrus.Entry, t *template.Template, prefix string, vars interface{}) bool
RenderRespond is a wrapper around RenderTemplate which will render a template and respond to the given message. It will return true on success and false on failure.
func RenderTemplate ¶
RenderTemplate is a wrapper to render a template to a string.
func TemplateMustCompile ¶
TemplateMustCompile will add all the helpers to a new template, compile it and panic if that fails. Note that it will also trim space from the start and end of the template to make definitions easier.
Provided functions: - dateFormat - takes one argument, the format of the date (in golang format) - pluralize - takes one argument, the number of something this is describing
Types ¶
type ContextKey ¶
type ContextKey string
func (ContextKey) String ¶
func (key ContextKey) String() string