Skip to content

Latest commit

 

History

History
25 lines (15 loc) · 648 Bytes

copylocks.md

File metadata and controls

25 lines (15 loc) · 648 Bytes

Pattern: Lock passed by value

Issue: -

Description

Lock can be passed by value or by pointer. Passing lock by value creates a copy of the lock and may cause unexpected behavior. This issue can be safely ignored if it's your intention.

Example of incorrect code:

func BadFunc(sync.Mutex) {} // BadFunc passes lock by value: sync.Mutex

Example of correct code:

func OkFunc(*sync.Mutex) {}

Further Reading