February 2018
Intermediate to advanced
340 pages
9h 43m
English
The sample code illustrates the lazy loading of the data while accessing the container structure. As the data should be loaded only once, the Once struct from the sync package is used in the method Pop. The Once implements only one method called Do which consumes the func with no arguments and the function is executed only once per Once instance, during the execution.
The Do method calls blocks until the first run is done. This fact corresponds with the fact that Once is intended to be used for initialization.
Read now
Unlock full access