invariant

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: BSD-2-Clause, BSD-2-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package invariant is the module's one assertion primitive (Power of Ten rule 5: assertions stay in production and have a recovery action).

Check has two behaviours selected by build tag:

  • with the tag softmagic_assert (every test, fuzz and CI run) a failed check panics with the message, so a violated invariant is a found bug;
  • without it (release) Check returns the condition, and the caller takes the recovery action: an error from Compile, or the entry under evaluation abandoned with Truncated: "invariant".

Conditions passed to Check must be side-effect free.

Index

Constants

View Source
const Enabled = false

Enabled reports whether a failed Check panics in this build.

Variables

This section is empty.

Functions

func Check

func Check(cond bool, _ string) bool

Check returns cond. The caller recovers when it is false.

Types

This section is empty.

Jump to

Keyboard shortcuts

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