package main import ( "fmt" "sync" ) type Counter struct { count int mutex sync.Mutex } func (c *Counter) Increment() { c.mutex.Lock() c.count++ c.mutex.Unlock() } func main() { c := Counter{} var wg sync.WaitGroup for i := 0; i < 1000; i++ { wg.Add(1) go func() { defer wg.Done() c.Increment() }() } wg.Wait() fmt.Println("Counter value:", c.count) }Here, the counter struct has an embedded Mutex. The Increment method acquires the lock on the mutex before incrementing the counter and then releases it after. The sync package is a standard library package, which means it is included with every installation of Go and does not require any external dependencies.