memoization function in Go