Skip to content

Instantly share code, notes, and snippets.

@amix
Last active August 29, 2015 13:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save amix/9517995 to your computer and use it in GitHub Desktop.
type Account struct {
balance float64
...
sync.Mutex
}
func (a *Account) Deposit(amount float64) {
a.Lock()
defer a.Unlock()
a.balance += amount
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment