must

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Unlicense Imports: 0 Imported by: 2

README

must

Contributor Covenant GitHub Go Report Card codecov GitHub Workflow Status (with event)

must is a dead simple library that includes (for now) single function - Do.

Contributing

You want to contibute? Hop into the CONTRIBUTING.md and find how you can help the project!

Documentation

Overview

Package must provides utility functions for handling errors with panics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do[T any](value T, err error) T

Do takes a value of any type and an error. If the error is not nil, it panics with the given error. Otherwise, it returns the value. This function is useful for handling errors that are not expected to occur and can be safely ignored or handled with a panic.

Example:

result := must.Do(someFunction())
// If someFunction() returns an error, the program will panic with that error.
// Otherwise, the result will be assigned the value returned by someFunction().

Types

This section is empty.

Jump to

Keyboard shortcuts

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