lang

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendStackTraceToPanics

func AppendStackTraceToPanics()

func Catch

func Catch(fn func()) (err error)

Catch handles panic values and returns any error caught

func Close

func Close(closeable io.Closer, context ...any)

func Default added in v0.0.2

func Default[T comparable](value T, defaultValue T) T

Default returns the first value that does not equal the type's default value

func HandleErrors

func HandleErrors()

HandleErrors is a utility to make errors and error codes handled prettier

func List

func List[T any](values ...T) []T

List returns a slice containing all the provided values, removing any nil or "empty" values

func Map

func Map[From, To any](values []From, mapFunc func(From) To) []To

Map returns a new slice with values mapped from incoming to outgoing in mapFunc

func Remove

func Remove[T comparable](values []T, shouldRemove func(T) bool) []T

Remove returns a new slice with values removed based on true returns from shouldRemove

func Return

func Return[T any](t T, e error) T

Return returns the provided value, panicking if a non-nil error is provided

func Return2

func Return2[T1, T2 any](t1 T1, t2 T2, e error) (T1, T2)

Return2 returns the provided values, panicking if a non-nil error is provided

func Throw

func Throw(e error)

Throw panics if the provided error is non-nil

Types

type OkError

type OkError struct{}

OkError is used to proceed normally

func (*OkError) Error

func (o *OkError) Error() string

type StackTraceError

type StackTraceError struct {
	Err      error
	ExitCode int
	Stack    []string
	Log      string
}

StackTraceError provides nicer stack information

func NewStackTraceError

func NewStackTraceError(err error) *StackTraceError

NewStackTraceError helps to capture nicer stack trace information

func (*StackTraceError) Error

func (s *StackTraceError) Error() string

func (*StackTraceError) Unwrap

func (s *StackTraceError) Unwrap() error

func (*StackTraceError) WithExitCode

func (s *StackTraceError) WithExitCode(exitCode int) *StackTraceError

func (*StackTraceError) WithLog

func (s *StackTraceError) WithLog(log string) *StackTraceError

Jump to

Keyboard shortcuts

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