README

Go Panics

Go Report Card GoDoc

import "github.com/ettle/panics"

Overview

Package panics implements some helper methods around panicing

While you should handle and return errors instead of throwing a panic (https://blog.golang.org/error-handling-and-go), there are times where having a runtime assertion is useful.

Index

func If

func If(condition bool, msgAndArgs ...interface{})

If will trigger a panic only if the condition is true

func IfEqual

func IfEqual(expected, actual interface{}, msgAndArgs ...interface{})

IfEqual will trigger a panic only if the expected and actual are equal

func IfError

func IfError(err error, msgAndArgs ...interface{})

IfError will trigger a panic only if the error is not nil

func IfNil

func IfNil(v interface{}, msgAndArgs ...interface{})

IfNil will trigger a panic only if the value is nil

func IfNot

func IfNot(condition bool, msgAndArgs ...interface{})

IfNot will trigger a panic only if the condition is false

func IfNotEqual

func IfNotEqual(expected, actual interface{}, msgAndArgs ...interface{})

IfNotEqual will trigger a panic only if the expected and actual are not equal

func IfNotError

func IfNotError(err error, msgAndArgs ...interface{})

IfNotError will trigger a panic only if the error is nil

func IfNotNil

func IfNotNil(v interface{}, msgAndArgs ...interface{})

IfNotNil will trigger a panic if the value is not nil

func Now

func Now(msgAndArgs ...interface{})

Now will trigger a panic

Expand ▾ Collapse ▴

Documentation

Overview

Package panics implements some helper methods around panicing

While you should handle and return errors instead of throwing a panic (https://blog.golang.org/error-handling-and-go), there are times where having a runtime assertion is useful.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func If

func If(condition bool, msgAndArgs ...interface{})

If will trigger a panic only if the condition is true

func IfEqual

func IfEqual(expected, actual interface{}, msgAndArgs ...interface{})

IfEqual will trigger a panic only if the expected and actual are equal

func IfError

func IfError(err error, msgAndArgs ...interface{})

IfError will trigger a panic only if the error is not nil

func IfNil

func IfNil(v interface{}, msgAndArgs ...interface{})

IfNil will trigger a panic only if the value is nil

func IfNot

func IfNot(condition bool, msgAndArgs ...interface{})

IfNot will trigger a panic only if the condition is false

func IfNotEqual

func IfNotEqual(expected, actual interface{}, msgAndArgs ...interface{})

IfNotEqual will trigger a panic only if the expected and actual are not equal

func IfNotError

func IfNotError(err error, msgAndArgs ...interface{})

IfNotError will trigger a panic only if the error is nil

func IfNotNil

func IfNotNil(v interface{}, msgAndArgs ...interface{})

IfNotNil will trigger a panic if the value is not nil

func Now

func Now(msgAndArgs ...interface{})

Now will trigger a panic

Types

This section is empty.

Source Files