Skip to content
masterclass Buddy

Go · Class

sync.Mutex

sync.Mutex provides mutual exclusion: one goroutine can hold the lock at a time. Lock waits for ownership, TryLock attempts without waiting, and Unlock releases the lock.

Last updated

Syntax

type Mutex struct
func (m *Mutex) Lock()
func (m *Mutex) TryLock() bool
func (m *Mutex) Unlock()

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • Lock
  • TryLock
  • Unlock
  • sync.Mutex
  • channel
  • WaitGroup

Source: src / internal / sync / mutex.go. Checked 2026-11-03.