Skip to content

Instantly share code, notes, and snippets.

@arriqaaq
Created January 27, 2023 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arriqaaq/58ad348dade7f0054d05911b1a6233bb to your computer and use it in GitHub Desktop.
Save arriqaaq/58ad348dade7f0054d05911b1a6233bb to your computer and use it in GitHub Desktop.
package main
import (
"image"
"sync"
)
var imageCache = sync.Map{}
func getImage(path string) image.Image {
if img, ok := imageCache.Load(path); ok {
return img.(image.Image)
}
img := loadImage(path)
imageCache.Store(path, img)
return img
}
func loadImage(path string) image.Image {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment