require

package
v0.0.0-...-c049333 Latest Latest
Warning

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

Go to latest
Published: May 7, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package require provides functions that to check conditions and panic when they are not met.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreEqual

func AreEqual[T comparable](x, y T)

AreEqual enforces that two values are equal to each other.

func AreNotEqual

func AreNotEqual[T comparable](x, y T)

AreNotEqual enforces that two value are NOT equal to each other.

func DirExists

func DirExists(path string)

DirExists enforces that the dir path already exists.

func FileExists

func FileExists(path string)

FileExists enforces that the file path already exists.

func IsFalse

func IsFalse(condition bool)

IsFalse enforces that a condition is false.

func IsGreaterThan

func IsGreaterThan[T constraints.Ordered](target, value T)

IsGreaterThan enforces that value > target.

func IsGreaterThanOrEquals

func IsGreaterThanOrEquals[T constraints.Ordered](target, value T)

IsGreaterThanOrEquals enforces that value >= target.

func IsInRange

func IsInRange[T constraints.Ordered](low, high, value T)

IsInRange enforces that value is between low and high, exclusive of high.

For example, 5 would meet the requirement with a low of 2 and a high of 10, but 10 would not.

func IsIndexInRange

func IsIndexInRange[T any](i int, slice []T)

IsIndexInRange enforces that index i is valid for the slice.

func IsLessThan

func IsLessThan[T constraints.Ordered](target, value T)

IsLessThan enforces that value < target.

func IsLessThanOrEquals

func IsLessThanOrEquals[T constraints.Ordered](target, value T)

IsLessThanOrEquals enforces that value <= target.

func IsNotZero

func IsNotZero[T comparable](x T)

IsNotZero enforces that a value is NOT set to its zero value.

func IsOfType

func IsOfType[T any](value T, t reflect.Type)

IsOfTYpe enforces that value is of type t.

func IsOfTypeBool

func IsOfTypeBool(value interface{})

IsOfTYpe enforces that value is of type bool.

func IsOfTypeFloat32

func IsOfTypeFloat32(value interface{})

IsOfTYpe enforces that value is of type float32.

func IsOfTypeFloat64

func IsOfTypeFloat64(value interface{})

IsOfTYpe enforces that value is of type float64.

func IsOfTypeInt

func IsOfTypeInt(value interface{})

IsOfTYpe enforces that value is of type int.

func IsOfTypeString

func IsOfTypeString(value interface{})

IsOfTYpe enforces that value is of type string.

func IsTrue

func IsTrue(condition bool)

IsTrue enforces that a condition is true.

func IsZero

func IsZero[T comparable](x T)

IsZero enforces that a value is set to its zero value.

func StringIsEmpty

func StringIsEmpty(s string)

StringIsEmpty enforces that a string has len of zero.

func StringIsNotEmpty

func StringIsNotEmpty(s string)

StringIsNotEmpty enforces that a string has a len greater than zero.

func StringIsNotWhitespaceOnly

func StringIsNotWhitespaceOnly(s string)

StringIsNotWhitespaceOnly enforces that a string is not empty or composed of only whitespace.

Types

This section is empty.

Jump to

Keyboard shortcuts

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