Inspectopedia
 
2024.3

Locks mistakenly passed by value

Warning
Reliability
New
Last modified: 03 December 2024

Reports locks that are mistakenly passed by values.

Accidentally copying a value containing a lock may cause both copies to work incorrectly. Generally, such values should be referred to through a pointer. A lock here means a type implementing sync.Locker, such as sync.Mutex or sync.WaitGroup.

Example:

After the Add pointer quick-fix is applied: