Documentation ¶
Overview ¶
Package memoize caches return values of functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Memoize ¶
func Memoize(fn interface{}) interface{}
Memoize takes a function and returns a function of the same type. The returned function remembers the return value(s) of the function call. Any pointer values will be used as an address, so functions that modify their arguments or programs that modify returned values will not work.
The returned function is safe to call from multiple goroutines if the original function is. Panics are handled, so calling panic from a function will call panic with the same value on future invocations with the same arguments.
The arguments to the function must be of comparable types. Slices, maps, functions, and structs or arrays that contain slices, maps, or functions cause a runtime panic if they are arguments to a memoized function. See also: https://golang.org/ref/spec#Comparison_operators
As a special case, variadic functions (func(x, y, ...z)) are allowed.
Types ¶
This section is empty.