Documentation
¶
Overview ¶
Package must implements
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CatchFunc ¶
CatchFunc takes a function f() => x that may panic, and instead returns a function f() => (x, error).
func Check ¶
Check panics if the error is not nil. Otherwise, it returns a nil error (so that it is convenient to chain).
func Func ¶
Func takes a function f() => (x, error), and returns a function f() => x that may panic in the event of error.
func Never ¶ added in v2.0.13
func Never(args ...interface{})
Never signifies code that should never be reached. It raises a panic when called.
The args parameter defines an optional fmt.Sprintf-style format string and arguments.
func Ok ¶
Ok accepts a (value, ok) tuple as input and panics if ok is false, otherwise returns value.
func Result ¶
Result accepts a (value, err) tuple as input and panics if err != nil, otherwise returns value. The error raised by panic is wrapped in another error.
For example, must.Result(os.Open("doesnotexist")) may panic with an error like "unexpected error in must.Result[*os.File]: open doesnotexist: no such file or directory". On success, returns *os.File
Types ¶
This section is empty.