Use more idiomatic form for lock.Unlock ( defer lock.Unlock() right after lock.Lock())