boolean

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 1 Imported by: 0

README

Boolean Functions

  • IsTrue: Checks if the provided string represents a true value (e.g., "T", "1", "TRUE").
  • Toggle: Toggles the given boolean value, returning its negation. (e.g., true becomes false and vice versa).
  • AllTrue: Checks if all the values in a slice of booleans are true. Returns false if the slice is empty.
  • AnyTrue: Checks if at least one value in a slice of booleans is true. Returns false if the slice is empty.
  • NoneTrue: Checks if none of the values in a slice of booleans are true. Returns true if the slice is empty.
  • CountTrue: Counts the number of true values in a slice of booleans. Returns 0 for an empty slice.
  • CountFalse: Counts the number of false values in a slice of booleans. Returns 0 for an empty slice.
  • Equal: Checks if all the values in a variadic boolean argument are equal. Returns true if the slice contains only one or no elements.
  • And: Performs a logical AND operation on all the values in a slice of booleans. Returns true only if all values are true. Returns false for an empty slice.
  • Or: Performs a logical OR operation on all the values in a slice of booleans. Returns true if at least one value is true. Returns false for an empty slice.

Examples:

For examples of each function, please checkout EXAMPLES.md


Documentation

Overview

Package boolean defines boolean helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllTrue added in v0.10.0

func AllTrue(values []bool) bool

AllTrue checks if all values in the slice are true.

Returns:

  • false if the slice is empty or contains at least one false value.
  • true if all values are true.

func And added in v0.10.0

func And(values []bool) bool

And performs a logical AND across all values in the slice.

Returns:

  • false if the slice is empty or any value is false.
  • true if all values are true.

func AnyTrue added in v0.10.0

func AnyTrue(values []bool) bool

AnyTrue checks if at least one value in the slice is true.

Returns:

  • false if the slice is empty or contains no true values.
  • true if at least one value is true.

func CountFalse added in v0.10.0

func CountFalse(values []bool) int

CountFalse counts the number of false values in the slice.

Returns:

  • The number of elements in the slice that are false.

func CountTrue added in v0.10.0

func CountTrue(values []bool) int

CountTrue counts the number of true values in the slice.

Returns:

  • The number of elements in the slice that are true.

func Equal added in v0.10.0

func Equal(values ...bool) bool

Equal checks if all values in the variadic argument list are equal.

Returns:

  • true if all values are the same (either all true or all false).
  • false if there is any inconsistency or the argument list is empty.

func IsTrue

func IsTrue(v string) bool

IsTrue checks if the provided string is a true value It accepts 1, t, T, TRUE, true, True. All other values are considered false.

func NoneTrue added in v0.10.0

func NoneTrue(values []bool) bool

NoneTrue checks if none of the values in the slice are true.

Returns:

  • true if the slice is empty or contains no true values.
  • false if at least one value is true.

func Or added in v0.10.0

func Or(values []bool) bool

Or performs a logical OR across all values in the slice.

Returns:

  • true if at least one value is true.
  • false if the slice is empty or all values are false.

func Toggle added in v0.10.0

func Toggle(value bool) bool

Toggle negates the given boolean value.

Returns:

  • true if the input is false.
  • false if the input is true.

Types

This section is empty.

Jump to

Keyboard shortcuts

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