util

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 8 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 DocsURL

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 Ellipsis

func Ellipsis(text string, maxLength int) string

Ellipsis returns a string that is at most maxLength characters with a ellipsis appended if the input was longer

func IsCollection

func IsCollection(kind reflect.Kind) bool

IsCollection is a check against slice and array

func IsNumeric

func IsNumeric(kind reflect.Kind) bool

IsNumeric returns whether the Kind is one of the numeric ones

func IsSignedInt

func IsSignedInt(kind reflect.Kind) bool

IsSignedInt is a check against the signed decimal types

func IsUnsignedInt

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

func MessageItemsFromLines(plain string, limits t.MessageLimit) (batches [][]t.MessageItem)

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

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

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 URLUserPassword

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