internal

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendStr

func AppendStr(strs []string, str string) []string

AppendStr appends string to slice with no duplicates.

func GetJSON

func GetJSON(url string, resp interface{}) error

GetJSON is a simple wrapper to get a json object from a given URL.

func IsSliceContainsStr

func IsSliceContainsStr(sl []string, str string) bool

IsSliceContainsStr returns true if the string exists in given slice, ignore case.

func Pluralize

func Pluralize(count int, word string) string

Pluralize attempts to pluralize the given word (and display the number) if count > 1

func PluralizeWord

func PluralizeWord(count int, word string) string

PluralizeWord attempts to pluralize the given word if count > 1

func PostJSON

func PostJSON(url string, data, resp interface{}) error

PostJSON is a simple wrapper to post and get JSON from a given url.

func PrettifyNumber

func PrettifyNumber(num int) string

PrettifyNumber displays a number with commas

func PrettifySuffix

func PrettifySuffix(num int) string

PrettifySuffix displays a semi-human-readable format such as 4k in place of 4125.

func RawPrettifySuffix

func RawPrettifySuffix(num, blockSize float64, suffixes []string) string

RawPrettifySuffix displays a semi-human-readable format such as 4k in place of 4125 with a number of weird options.

func RenderTemplate

func RenderTemplate(t *template.Template, tag string, vars interface{}) (string, error)

RenderTemplate is a wrapper to render a template to a string.

func TemplateMustCompile

func TemplateMustCompile(name, data string) *template.Template

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 Duration

type Duration struct {
	time.Duration
}

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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