Since the Graph struct contains a mutex, misbehaviors can occur if this struct is copied by pass-by-value returns. GraphNew instantiates and returns a Graph value, but this is safe because no other copies of the object exist.
The DeepSource complaint can be simply avoided by returning the new Graph struct directly rather than assigning it to a local variable first.
Since the
Graph
struct contains a mutex, misbehaviors can occur if this struct is copied by pass-by-value returns.GraphNew
instantiates and returns aGraph
value, but this is safe because no other copies of the object exist.The
DeepSource
complaint can be simply avoided by returning the newGraph
struct directly rather than assigning it to a local variable first.