flexcall

package module
v0.0.0-...-2215eb4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: MIT Imports: 3 Imported by: 1

README

flexcall

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnmatched = errors.New("could not find a match for argument")

Functions

func Call

func Call(f interface{}, args ...interface{}) ([]interface{}, error)

Call given function f with arguments args. Arguments will be supplied to f based on their types. If any given argument does not match - no error is returned. If any argument expected by f is not matched, an error wrapping ErrUnmatched is returned and f is not called. See tests for examples.

func CallAndExtractError

func CallAndExtractError(f interface{}, args ...interface{}) ([]interface{}, error)

func CallOptional

func CallOptional(f interface{}, args ...interface{}) ([]interface{}, error)

CallOptional behaves the same way as Call, but if any value is unfulfilled, its zero value will be set instead of erroring out.

func CallOptionalAndExtractError

func CallOptionalAndExtractError(f interface{}, args ...interface{}) ([]interface{}, error)

func ExtractError

func ExtractError(f interface{}, outs []interface{}) ([]interface{}, error)

ExtractError splits the input arguments into non-error and error parts. An error is considered only if it is the last item in the given arguments. f is the function which its return values are supplied in outs. This is necessary as an nil error does not carry a type in outs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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