Documentation ¶
Overview ¶
Package assert is a helper to allow assert tests in a more standardized and simple manner. Using it makes it clear the this is an assertion used in non production setting.
Index ¶
Constants ¶
const DEBUG = false
DEBUG if this is set to "true" asserts are evaluated.
Variables ¶
This section is empty.
Functions ¶
func Assert ¶
Assert runs the provided function and throws panic with the given message if the test evaluates to false. Unfortunately GO still executes parameters (e.g. value.String() of calls to this even if the function is a null function when DEBUG is set to false. So it is necessary to also have a if assert.DEBUG {} wrapper around calls to this to really avoid any run time impact. The GO compiler will then eliminate the whole statement if DEBUG as a const is set to false. Example:
if assert.DEBUG { assert.Assert(value > 0, "Error message if test fails %s", value.String()) }
Types ¶
This section is empty.