must

package
v0.1.29 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package must provide a set of functions that check for errors and panic on error.

Convenient for writing command-line tools that need to fail on error, or tests.

Copied from https://github.com/janpfeifer/must

Index

Constants

This section is empty.

Variables

View Source
var M = func(err error) {
	if err != nil {
		klog.Errorf("Must not error: %+v\nPanicking ...\n\n", err)
		panic(err)
	}
}

M logs and panics if `err` is not nil.

This function is used by all other variants (M1, ..., M9), and if you want a different error behavior (like `log.Fatalf` or similar), just reassign M to your particular use, and all other functions will pick it up.

Functions

func M1

func M1[T1 any](value1 T1, err error) T1

M1 checks that there is no error with `M(err)` and then simply returns the values given.

func M2

func M2[T1 any, T2 any](value1 T1, value2 T2, err error) (T1, T2)

M2 checks that there is no error with `M(err)` and then simply returns the values given.

func M3

func M3[T1 any, T2 any, T3 any](value1 T1, value2 T2, value3 T3, err error) (T1, T2, T3)

M3 checks that there is no error with `M(err)` and then simply returns the values given.

func M4

func M4[T1 any, T2 any, T3 any, T4 any](value1 T1, value2 T2, value3 T3, value4 T4, err error) (T1, T2, T3, T4)

M4 checks that there is no error with `M(err)` and then simply returns the values given.

func M5

func M5[T1 any, T2 any, T3 any, T4 any, T5 any](value1 T1, value2 T2, value3 T3, value4 T4, value5 T5, err error) (T1, T2, T3, T4, T5)

M5 checks that there is no error with `M(err)` and then simply returns the values given.

func M6

func M6[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any](value1 T1, value2 T2, value3 T3, value4 T4, value5 T5, value6 T6, err error) (T1, T2, T3, T4, T5, T6)

M6 checks that there is no error with `M(err)` and then simply returns the values given.

func M7

func M7[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any](value1 T1, value2 T2, value3 T3, value4 T4, value5 T5, value6 T6, value7 T7, err error) (T1, T2, T3, T4, T5, T6, T7)

M7 checks that there is no error with `M(err)` and then simply returns the values given.

func M8

func M8[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any](value1 T1, value2 T2, value3 T3, value4 T4, value5 T5, value6 T6, value7 T7, value8 T8, err error) (T1, T2, T3, T4, T5, T6, T7, T8)

M8 checks that there is no error with `M(err)` and then simply returns the values given.

func M9

func M9[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any, T9 any](value1 T1, value2 T2, value3 T3, value4 T4, value5 T5, value6 T6, value7 T7, value8 T8, value9 T9, err error) (T1, T2, T3, T4, T5, T6, T7, T8, T9)

M9 checks that there is no error with `M(err)` and then simply returns the values given.

Types

This section is empty.

Jump to

Keyboard shortcuts

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