Skip to content

Instantly share code, notes, and snippets.

@madflojo
Created September 3, 2022 19:17
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 madflojo/73baa7b2c15c1f50180711d1dea0b591 to your computer and use it in GitHub Desktop.
Save madflojo/73baa7b2c15c1f50180711d1dea0b591 to your computer and use it in GitHub Desktop.
ThreadSafe Packages - Copy Map
// 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