function

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: MIT Imports: 0 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetFirstReturnElement = MakeGetReturnElementAt(0)
View Source
var GetLastReturnElement = MakeGetReturnElementAt(-1)

Functions

func MakeGetReturnElementAt

func MakeGetReturnElementAt(index int) func(...interface{}) interface{}

MakeGetReturnElementAt Returns a function which, if provided multiple arguments, returns the argument at position index. May be used on functions that return multiple values but where we want to ignore all except one. Example: func do() (int64, string, error) { return 0, "", errors.New("error") } Example 1: MakeGetReturnElementAt(0)(do()).(int64) // yields the first element, i.e., just the int64 and ignores the string and the error (you will have to check if this can be done safely) Example 2: MakeGetReturnElementAt(-1)(do()).(error) // yields the last element, i.e., just the error and ignores the int64 and the string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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