panics

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: MIT Imports: 2 Imported by: 0

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

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.

Jump to

Keyboard shortcuts

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