util

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capitalize

func Capitalize(s string) string

func ColoredUnifiedDiff

func ColoredUnifiedDiff(from, to string, diffContextLines int) string

func EscapeForMarkdown added in v1.21.0

func EscapeForMarkdown(s string) string

EscapeForMarkdown escapes all Markdown special characters in the input string by prefixing them with a backslash.

func EscapeForMarkdownPreservingCodeSpans added in v1.21.0

func EscapeForMarkdownPreservingCodeSpans(s string) string

EscapeForMarkdownPreservingCodeSpans escapes Markdown special characters but preserves text within backtick code spans and indented code blocks.

func JSONPatchPathToJSONPath added in v1.13.0

func JSONPatchPathToJSONPath(path string) string

func MergeJSON added in v1.13.0

func MergeJSON(mergeA, toB []byte) (result []byte, changed bool, err error)

func NewRestyClient added in v1.21.0

func NewRestyClient(ctx context.Context) *resty.Client

func ParseProperties

func ParseProperties(ctx context.Context, input string) (map[string]any, error)

This is a pretty well-thought-out properties parser using a finite state machine (FSM). We should use it more, especially in annotations.

func SubtractJSON added in v1.13.0

func SubtractJSON(fromA, subtractB []byte) (result []byte, changed bool, err error)

func Uint64ToInt added in v1.13.0

func Uint64ToInt(v uint64) int

Types

type MultiError added in v1.21.0

type MultiError struct {
	// contains filtered or unexported fields
}

MultiError collects multiple errors and formats them as a flat list. Nested MultiErrors wrapped with fmt.Errorf are automatically flattened, with wrapper prefixes prepended to each inner error.

func (*MultiError) Add added in v1.21.0

func (m *MultiError) Add(errs ...error) *MultiError

Add appends errors to the collection. Nil errors are ignored. Returns the MultiError for chaining.

func (*MultiError) Error added in v1.21.0

func (m *MultiError) Error() string

Error returns formatted error string. Single error is returned as-is. Multiple errors are formatted as "N errors occurred:\n * err1\n * err2". Nested MultiErrors are flattened with their wrapper chain as prefix.

func (*MultiError) HasErrors added in v1.21.0

func (m *MultiError) HasErrors() bool

func (*MultiError) OrNilIfNoErrs added in v1.21.0

func (m *MultiError) OrNilIfNoErrs() error

func (*MultiError) Unwrap added in v1.21.0

func (m *MultiError) Unwrap() []error

Jump to

Keyboard shortcuts

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