Documentation
¶
Overview ¶
Package must provides panic-on-error helpers for enforcing invariants.
Use must for startup-time configuration, code generation, tests, and programmer-error invariants — cases where failure means a bug or misconfiguration, not a recoverable runtime condition.
Do not use must for user input, expected I/O failures, or exported library APIs unless panic semantics are explicitly part of the contract.
BeNil, Get, Get2, and Of panic with the original error value, preserving error chains for errors.Is/errors.As after recovery. NonEmptyEnv panics with a descriptive error wrapping ErrEnvUnset or ErrEnvEmpty for machine-checkable classification after recovery.
Of panics immediately if given a nil function, wrapping ErrNilFunction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEnvEmpty = errors.New("environment variable empty")
ErrEnvEmpty indicates the environment variable is set but empty.
var ErrEnvUnset = errors.New("environment variable unset")
ErrEnvUnset indicates the environment variable is not set.
var ErrNilFunction = errors.New("nil function")
ErrNilFunction indicates a nil function was passed where one is required.
Functions ¶
func Get ¶
Get returns the value of a (value, error) pair of arguments unless error is non-nil. In that case, it panics.
func Get2 ¶
Get2 returns the value of a (value, value, error) set of arguments unless error is non-nil. In that case, it panics.
func NonEmptyEnv ¶ added in v0.41.0
NonEmptyEnv returns the value of the environment variable named by key. It panics if the variable is unset or empty. The panic value wraps ErrEnvUnset or ErrEnvEmpty for errors.Is matching.
func Of ¶
Of returns the "must" version of fn. fn must be a single-argument function. Panics immediately if fn is nil, wrapping ErrNilFunction.
Types ¶
This section is empty.