Back to godoc.org

Package must

v0.0.9
Latest Go to latest
Published: Jun 24, 2020 | License: Apache-2.0 | Module: github.com/grailbio/base

Overview

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

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

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

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

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

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

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

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.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier