Documentation
¶
Index ¶
- func EllipsisURL(urlString string, truncateThreshold int) string
- func ExtensionlessFileName(filePath string) string
- func FirstElementOfPath(path string) string
- func IOCopyWithContext(ctx context.Context, dst io.Writer, src io.Reader) (int64, error)
- func IsNil(v interface{}) bool
- func JoinNonEmpty(stringList []string, sep string) string
- func LogPanic()
- func LogRecoveredValue(r interface{})
- func MakePathAbsolute(path string, absoluteReferencePath string) string
- func MustGetRandomHexString(byteCount int) string
- func MustJoinURL(base, reference string) string
- func MustParseURL(urlString string) *url.URL
- func MustReadAll(fromReader io.Reader) []byte
- func MustStripLastURLPathElement(urlString string) string
- func MustUnmarshalJSON(data []byte, v interface{})
- func MustWaitForContext(ctx context.Context, timeout time.Duration)
- func NewUserErrorFromErrors(errs ...error) error
- func RemoveLines(s string, from, to int) (string, error)
- func RuneIndexToByteIndex(s string, runeIndex int) int
- func ShortString(s string, leadingCount int, trailingCount int) string
- func SplitTrailing(s string, trailSet string) (lead, trail string)
- func StripFirstPathElement(filePath string, sep rune) (newPath, strippedElement string)
- func StripTrailingLineBreak(s string) string
- func TryRemoveLines(s string, from, to int) string
- func UserErrorf(cause error, userMessageFormat string, args ...interface{}) error
- func WaitCancelable(ctx context.Context, c <-chan struct{})
- func WaitForContext(ctx context.Context, timeout time.Duration) error
- func WaitForSignal(c <-chan struct{}, timeout time.Duration) bool
- func WordWrap(text string, lineWidth int) string
- func WordWrapIgnoreNewLine(text string, lineWidth int) string
- func WriteAttempter(c chan<- struct{}) func()
- type UserError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EllipsisURL ¶
func ExtensionlessFileName ¶
func FirstElementOfPath ¶
func IOCopyWithContext ¶ added in v1.3.3
IOCopyWithContext performs a cancelable io.Copy
func IsNil ¶
func IsNil(v interface{}) bool
IsNil returns true if v holds a nil reference, even if it is a typed nil interface value.
func JoinNonEmpty ¶
func LogPanic ¶
func LogPanic()
LogPanic temporarily recovers from a panic (if there is one) and then logs it with Panicf() of Go's log library so that a writer attached with log.SetOutput() can deal with it (e.g. log it to a file), then lets the panic resume.
func LogRecoveredValue ¶ added in v1.3.2
func LogRecoveredValue(r interface{})
func MakePathAbsolute ¶
func MustGetRandomHexString ¶
func MustJoinURL ¶
func MustParseURL ¶
func MustReadAll ¶
func MustUnmarshalJSON ¶
func MustUnmarshalJSON(data []byte, v interface{})
func NewUserErrorFromErrors ¶ added in v1.5.0
NewUserErrorFromErrors returns the first non-nil error in the variadic parameter list if it is a *UserError. If the first non-nil error is not a *UserError, one is built using UserErrorf() with a generic message revealing the result of Error().
func RuneIndexToByteIndex ¶
func SplitTrailing ¶ added in v1.3.2
func StripFirstPathElement ¶
func StripTrailingLineBreak ¶
func TryRemoveLines ¶
func UserErrorf ¶ added in v1.5.0
UserErrorf constructs a new *UserError with given cause and formatted message. The message should start with a capital letter and have proper punctuation - but no word-wrapping line-breaks - for display in a dialog.
func WaitCancelable ¶ added in v1.4.0
func WaitForSignal ¶
func WordWrap ¶
WordWrap performs word-wrapping on space-separated words within text, keeping existing newline characters intact. Any words which exceed lineWidth in length will move to a new line, but words themself will never be split.
func WordWrapIgnoreNewLine ¶
WordWrapIgnoreNewLine performs word-wrapping on space-separated words within text, whereas any newline characters are treated as spaces themselves. Any words which exceed lineWidth in length will move to a new line, but words themself will never be split.
func WriteAttempter ¶ added in v1.4.0
func WriteAttempter(c chan<- struct{}) func()
Types ¶
type UserError ¶ added in v1.5.0
type UserError struct {
// contains filtered or unexported fields
}
UserError is an error with a cause-agnostic message and the added semantic of that message being suitable for display to users, i.e. non-programmers. It allows you to construct an error which will return a cause with Unwrap(), without the unwrapped error's message appearing in strings returned from Message().