O'Reilly logo

Go Standard Library Cookbook by Radomir Sohlich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

The package sync, contains the structure Map that is designed to be used concurrently from multiple Go routines. The Map struct, with its methods, mimics the behavior of the map primitive. The Store method is the equivalent of the m[key] = val statement. The Load method is equal to val, ok := m[key] and the  Range method provides the ability to iterate through the map. Note that the Range function works with the current state of Map, so if the values are changed during the running Range method, the changes are reflected, but only if the key wasn't already visited. The Range function visits its keys only once.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required