cmp

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package cmp implements the functions, types, and interfaces for the module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Excludes

func Excludes[T comparable](src []T, ts ...T) []T

Excludes returns the elements in src that are not in ts.

func Has

func Has[T comparable](s []T, e T) bool

Has checks whether a value is in a slice.

func If added in v0.2.5

func If[T any](condition bool, trueVal T, falseVal T) T

If function takes a boolean condition and two values of any type T, and returns the first value if the condition is true, and the second value if the condition is false.

func IfFunc added in v0.2.5

func IfFunc[T any](condition bool, trueFn func() T, falseFn func() T) T

IfFunc function takes a boolean condition, a function to execute if the condition is true, and a function to execute if the condition is false. It returns the result of the function that was executed.

func IfFuncWithError added in v0.2.5

func IfFuncWithError[T any](condition bool, trueFn func() (T, error), falseFn func() (T, error)) (T, error)

IfFuncWithError function takes a boolean condition, a function to execute if the condition is true, and a function to execute if the condition is false. It returns the result of the function that was executed.

func Includes

func Includes[T comparable](src []T, ts ...T) []T

Includes returns the elements in src that are in ts.

func IsZero

func IsZero[T comparable](v T) bool

IsZero returns true if the value is zero.

func Or

func Or[T comparable](vals ...T) T

Or returns the first non-zero value.

func ZeroOr

func ZeroOr[T comparable](v T, rv T) T

ZeroOr returns right value if v is the zero value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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