util

package
v0.0.0-...-1a9902f Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: AGPL-3.0, AGPL-3.0-or-later Imports: 4 Imported by: 0

Documentation

Overview

Package util contains various general utility functions used throughout the project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneBytes

func CloneBytes(b []byte) []byte

CloneBytes creates a copy of b

func ConcatStrings

func ConcatStrings(s ...string) string

ConcatStrings efficiently concatenates strings with only one extra allocation

func HashBuffer

func HashBuffer(buf []byte) string

HashBuffer computes a base64 MD5 hash from a buffer

func Parallel

func Parallel(fns ...func() error) error

Parallel executes functions in parallel. The first error is returned, if any.

func SplitPunctuation

func SplitPunctuation(word []byte) (leading byte, mid []byte, trailing byte)

SplitPunctuation splits off one byte of leading and trailing punctuation, if any, and returns the 3 split parts. If there is no edge punctuation, the respective byte = 0.

func SplitPunctuationString

func SplitPunctuationString(word string) (
	leading byte, mid string, trailing byte,
)

SplitPunctuationString splits off one byte of leading and trailing punctuation, if any, and returns the 3 split parts. If there is no edge punctuation, the respective byte = 0.

func TrimString

func TrimString(s *string, maxLen int)

Trim string, while making sure it's still valid unicode, in case a rune was split in half

func Waterfall

func Waterfall(fns ...func() error) (err error)

Waterfall executes a slice of functions until the first error returned. This error, if any, is returned to the caller.

func WrapError

func WrapError(text string, err error) error

WrapError wraps error types to create compound error chains

Types

type WrappedError

type WrappedError struct {
	Text  string
	Inner error
}

WrappedError wraps error types to create compound error chains

func (WrappedError) Error

func (e WrappedError) Error() string

Jump to

Keyboard shortcuts

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