• 0 Posts
  • 7 Comments
Joined 1 year ago
cake
Cake day: June 11th, 2023

help-circle





  • wyrmroot@programming.devtoGolang@programming.devMemoization in Go
    ·
    edit-2
    1 year ago

    In applications where I’ve needed this, I’ve taken a manual approach. Structure the function to return a single Result struct (including an error field), develop a convention for mapping function inputs to a string, then add reads & writes to a map[string]*Result which allows me to return cached values as a shortcut. No idea if it’s the most efficient way, I’ve not actually considered finding a package to handle the process.

    Edit: For more advanced behavior, what are your thoughts on the official memoize package?