op

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2025 License: MIT Imports: 3 Imported by: 6

Documentation

Overview

Package op provides generic operations that can be used for converting or reducing collections, loops, slices

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare added in v0.0.11

func Compare[O cmp.Ordered](o1, o2 O) int

Compare returns -1 if o1 less than o2, 0 if equal and 1 if 01 more tha o2.

func Get added in v0.0.10

func Get[T any](getter func() T) T

Get calls the getter and returns the result.

func IfElse added in v0.0.4

func IfElse[T any](ok bool, tru, fal T) T

IfElse returns the tru value if ok, otherwise returns the fal value.

func IfElseErr added in v0.0.8

func IfElseErr[T any](ok bool, tru T, err error) (T, error)

IfElseErr returns the tru value if ok, otherwise returns the specified error.

func IfElseErrf added in v0.0.17

func IfElseErrf[T any](ok bool, tru T, format string, a ...any) (T, error)

IfElseErrf returns the tru value if ok, otherwise returns an error creating by fmt.Errorf.

func IfElseGet added in v0.0.17

func IfElseGet[T any](ok bool, tru T, fal func() T) T

IfElseGet returns the tru value if ok, otherwise exec the fal function and returns it result.

func IfElseGetErr added in v0.0.17

func IfElseGetErr[T any](ok bool, tru T, err func() error) (T, error)

IfElseGetErr returns the tru value if ok, otherwise returns an error returnet by the err function.

func IfElseGetWithErr added in v0.0.17

func IfElseGetWithErr[T any](ok bool, tru T, fal func() (T, error)) (T, error)

IfElseGetWithErr executes the tru func if ok, otherwise exec the fal function and returns it result.

func IfGetElse added in v0.0.8

func IfGetElse[T any](ok bool, tru func() T, fal T) T

IfGetElse executes the tru value if ok, otherwise returns the fal value.

func IfGetElseGet added in v0.0.17

func IfGetElseGet[T any](ok bool, tru, fal func() T) T

IfGetElseGet executes the tru func if ok, otherwise exec the fal function and returns it result.

func IfGetElseGetErr added in v0.0.8

func IfGetElseGetErr[T any](ok bool, tru func() T, fal func() error) (T, error)

IfGetElseGetErr executes the tru func if ok, otherwise exec the fal function and returns its error.

func Max added in v0.0.3

func Max[T cmp.Ordered](a T, b T) T

Max returns the maximum from two operands.

func Min added in v0.0.3

func Min[T cmp.Ordered](a T, b T) T

Min returns the minimum from two operands.

func Sub added in v0.0.3

func Sub[T Number](a T, b T) T

Sub returns the subtraction of the b from the a.

func Sum added in v0.0.3

func Sum[T Summable](a T, b T) T

Sum returns the sum of two operands.

Types

type Number added in v0.0.17

type Number interface {
	constraints.Integer | constraints.Float | constraints.Complex
}

Number is a type that supports the operators +, -, /, *.

type Summable added in v0.0.17

type Summable interface {
	cmp.Ordered | constraints.Complex | string
}

Summable is a type that supports the operator +.

Directories

Path Synopsis
Package check provides common predicate functions
Package check provides common predicate functions
not
Package not provides negalive predicates like 'not equals to'
Package not provides negalive predicates like 'not equals to'
Package delay provides functions that return anonymous functions for delayed executions.
Package delay provides functions that return anonymous functions for delayed executions.
chain
Package chain provides functions call chain builder
Package chain provides functions call chain builder
replace
Package replace provides builders that specifies on value replacing
Package replace provides builders that specifies on value replacing
string_
Package string_ provides string builders
Package string_ provides string builders
string_/join
Package join provides string builders
Package join provides string builders
string_/wrap
Package wrap provides wrap string builders
Package wrap provides wrap string builders
sum
Package sum provides sum.Of alias
Package sum provides sum.Of alias
Package string_ provides string utils
Package string_ provides string utils
join
Package join provides concatenate string utils
Package join provides concatenate string utils
wrap
Package wrap provides string wrap utils
Package wrap provides string wrap utils
Package sum provides sum.Of alias
Package sum provides sum.Of alias

Jump to

Keyboard shortcuts

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