Created
September 3, 2022 19:17
-
-
Save madflojo/73baa7b2c15c1f50180711d1dea0b591 to your computer and use it in GitHub Desktop.
ThreadSafe Packages - Copy Map
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
// Directory will return a map of all people stored within the Directory. | |
func (d *Directory) Directory() map[string]Person { | |
d.RLock() | |
defer d.RUnlock() | |
m := make(map[string]Person) | |
for k, v := range d.directory { | |
m[k] = v | |
} | |
return m | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment