Generic memoization support for Go