Documentation
¶
Index ¶
- func AppName() string
- func BatchSliceOfStrings(ctx context.Context, keys []string, count int) <-chan []string
- func ChanFromSlice[T any](values []T) <-chan T
- func Checksum(data interface{}) []byte
- func Ellipsize(s string, limit int) string
- func IsContextCanceled(err error) bool
- func IsDeadlock(err error) bool
- func IsUnixAddr(host string) bool
- func IterateOrderedMap[K cmp.Ordered, V any](m map[K]V) iter.Seq2[K, V]
- func JoinHostPort(host string, port int) string
- func PrintErrorThenExit(err error, exitCode int)
- func RawUrlEncode(s string) string
- func Timed(start time.Time, callback func(elapsed time.Duration))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppName ¶
func AppName() string
AppName returns the name of the executable that started this program (process).
func BatchSliceOfStrings ¶
BatchSliceOfStrings groups the given keys into chunks of size count and streams them into a returned channel. Panics if count is less than or equal to zero.
func ChanFromSlice ¶
func ChanFromSlice[T any](values []T) <-chan T
ChanFromSlice takes a slice of values and returns a channel from which these values can be received. This channel is closed after the last value was sent.
func Checksum ¶
func Checksum(data interface{}) []byte
Checksum returns the SHA-1 checksum of the data.
func IsContextCanceled ¶
IsContextCanceled returns whether the given error is context.Canceled.
func IsDeadlock ¶
IsDeadlock returns whether the given error signals serialization failure.
func IsUnixAddr ¶
IsUnixAddr indicates whether the given host string represents a Unix socket address.
A host string that begins with a forward slash ('/') is considered Unix socket address.
func IterateOrderedMap ¶ added in v0.7.0
IterateOrderedMap implements iter.Seq2 to iterate over a map in the key's order.
This function returns a func yielding key-value-pairs from a given map in the order of their keys, if their type is cmp.Ordered.
func JoinHostPort ¶
JoinHostPort is like its equivalent in net., but handles UNIX sockets as well.
func PrintErrorThenExit ¶
PrintErrorThenExit prints the given error to os.Stderr and exits with the specified error code.
func RawUrlEncode ¶ added in v0.8.0
RawUrlEncode mimics PHP's rawurlencode to be used for parameter encoding.
Icinga Web uses rawurldecode instead of urldecode, which, as its main difference, does not honor the plus char ('+') as a valid substitution for space (' '). Unfortunately, Go's url.QueryEscape does this very substitution and url.PathEscape does a bit too less and has a misleading name on top.
Types ¶
This section is empty.