helper

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(fn interface{}, params ...interface{}) interface{}

Call calls the given function with the given params.

Example:

Call(func(name string) string {
	return "Hello " + name
}, "world")

func CallWithCtx

func CallWithCtx(ctx interface{}, fn interface{}, params ...interface{}) interface{}

CallWithCtx calls the given function with the given context and params.

Example:

type Foo struct {
	Name string
}

result := CallWithCtx(&Foo{Name: "Hello"}, func(ts *Foo, name string) string {
	return ts.Name + name
}, "world")

func Retry

func Retry(fn func() error, max int) error

Retry retries the given function until it returns nil or max is reached.

Example:

err := Retry(func() error {
	return nil
}, 3)

func Tap

func Tap(value interface{}, callbacks ...func(interface{})) interface{}

Tap calls the given callback with the given value then returns the value.

func ValueOf

func ValueOf(src interface{}, dest interface{}) error

ValueOf sets the value of dest to the value of src.

Example:

var foo string
ValueOf("bar", &foo)

func With

func With(value interface{}, callbacks ...func(interface{}) interface{}) interface{}

With calls the given callbacks with the given value then return the value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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