base: github.com/grailbio/base/must Index | Files

package must

import "github.com/grailbio/base/must"

Package must provides a handful of functions to express fatal assertions in Go programs. It is meant to alleviate cumbersome error handling and reporting when the only course of action is to fail the program. Package must is intended to be used by top-level binaries (i.e., in main packages); it should rarely be used elsewhere.

Index

Package Files

must.go

Variables

var Func func(...interface{}) = log.Panic

Func is the function called to report an error and interrupt execution. Func is typically set to log.Panic or log.Fatal. It should be set before any potential calls to functions in the must package.

func Never Uses

func Never(v ...interface{})

Never asserts that it is never called. If it is, it formats a message in the manner of fmt.Sprint and calls Func.

func Neverf Uses

func Neverf(format string, v ...interface{})

Neverf asserts that it is never called. If it is, it formats a message in the manner of fmt.Sprintf and calls Func.

func Nil Uses

func Nil(v interface{}, args ...interface{})

Nil asserts that v is nil; v is typically a value of type error. If v is not nil, Nil formats a message in hte manner of fmt.Sprint and calls must.Func. Nil also suffixes the message with the fmt.Sprint-formatted value of v.

func Nilf Uses

func Nilf(v interface{}, format string, args ...interface{})

Nilf asserts that v is nil; v is typically a value of type error. If v is not nil, Nilf formats a message in hte manner of fmt.Sprintf and calls must.Func. Nilf also suffixes the message with the fmt.Sprint-formatted value of v.

func True Uses

func True(b bool, v ...interface{})

True is a no-op if the value b is true. If it is false, True formats a message in the manner of fmt.Sprint and calls Func.

func Truef Uses

func Truef(x bool, format string, v ...interface{})

Truef is a no-op if the value b is true. If it is false, True formats a message in the manner of fmt.Sprintf and calls Func.

Package must imports 2 packages (graph) and is imported by 8 packages. Updated 2019-12-01. Refresh now. Tools for package owners.