util

package
Version: v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DiscardLogger = log.New(ioutil.Discard, "", 0)

DiscardLogger is a logger that discards any output written to it

Functions

func CeilDiv added in v0.4.0

func CeilDiv(dividend int, divisor int) int

CeilDiv returns the quotient from dividing the dividend with the divisor, but rounded up to the nearest integer

func DocsURL added in v0.5.0

func DocsURL(path string) string

DocsURL returns a full documentation URL for the current version of Shoutrrr with the path appended. If the path contains a leading slash, it is stripped.

func IsCollection

func IsCollection(kind reflect.Kind) bool

IsCollection is a check against slice and array

func IsNumeric added in v0.4.0

func IsNumeric(kind reflect.Kind) bool

IsNumeric returns whether the Kind is one of the numeric ones

func IsSignedInt added in v0.4.0

func IsSignedInt(kind reflect.Kind) bool

IsSignedInt is a check against the signed decimal types

func IsUnsignedInt added in v0.4.0

func IsUnsignedInt(kind reflect.Kind) bool

IsUnsignedInt is a check against the unsigned integer types

func Max

func Max(a int, b int) int

Max returns the largest of a and b

func MessageItemsFromLines added in v0.4.0

func MessageItemsFromLines(plain string, limits t.MessageLimit) (items []t.MessageItem, omitted int)

MessageItemsFromLines creates a set of MessageItems that is compatible with the supplied limits

func Min

func Min(a int, b int) int

Min returns the smallest of a and b

func PartitionMessage added in v0.4.0

func PartitionMessage(input string, limits t.MessageLimit, distance int) (items []t.MessageItem, omitted int)

PartitionMessage splits a string into chunks that is at most chunkSize runes, it will search the last distance runes for a whitespace to make the split appear nicer. It will keep adding chunks until it reaches maxCount chunks, or if the total amount of runes in the chunks reach maxTotal. The chunks are returned together with the number of omitted runes (that did not fit into the chunks)

func StripNumberPrefix added in v0.4.0

func StripNumberPrefix(input string) (number string, base int)

StripNumberPrefix returns a number string with any base prefix stripped and it's corresponding base If no prefix was found, returns 0 to let strconv try to identify the base

func TestLogger

func TestLogger() *log.Logger

TestLogger returns a log.Logger that writes to ginkgo.GinkgoWriter for use in tests

func URLMust added in v0.5.0

func URLMust(rawURL string) *url.URL

func URLUserPassword added in v0.4.2

func URLUserPassword(user, password string) *url.Userinfo

URLUserPassword is a replacement/wrapper around url.UserPassword that treats empty string arguments as not specified If no user or password is specified, it returns nil (which serializes in url.URL to "")

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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