Hacker symbol

November 26, 2019 ~ 1 min read

Mutex and locking

import (

type Account struct {
   balance int64
   closed  bool

 func (a *Account) Close() (payout int64, ok bool) {
   // This makes sure that only this function can change the contents
   // Afterthe function is done it will unlocked no matter what happens
   // in this function
   defer a.Unlock()
   payout = a.balance

Sebastian BolaƱos

Hi, I'm Sebastian. I'm a software developer from Costa Rica. You can follow me on Twitter. I enjoy working on trustless systems.