Created
November 24, 2023 11:47
-
-
Save yumed15/4bf00fa2d071f037e763fef63f90a032 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var once sync.Once | |
var myResource *Resource | |
func initializeResource() { | |
myResource = createResource() | |
} | |
func getResource() *Resource { | |
once.Do(initializeResource) | |
return myResource | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment