Skip to content

Instantly share code, notes, and snippets.

@jasonkeene
Created April 30, 2020 18:05
Show Gist options
  • Save jasonkeene/0b0507c354b7cc08f80bfe163307b4a6 to your computer and use it in GitHub Desktop.
Save jasonkeene/0b0507c354b7cc08f80bfe163307b4a6 to your computer and use it in GitHub Desktop.
type ExportedType struct {
unguarded int
// iternal state that is subject to concurrent access and requires locking
protected struct {
sync.RWMutex
guarded1 int
guarded2 int
guarded3 int
}
}
func (e *ExportedType) Method() {
e.protected.Lock()
defer e.protected.Unlock()
// monkey with e.protected
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment