Documentation ¶
Overview ¶
Package leak provides a way to track resources when race detector is enabled.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ref ¶
type Ref struct { }
Ref implements a Resource tracker that is only enabled when compiling with `-race`.
func FromContext ¶
FromContext returns the attached root Ref.
func WithContext ¶
WithContext attaches a root context that handles tracking.
func (Ref) Close ¶
Close closes the ref and checks whether all the children have been closed.
The caller should close the ref with Ref.Close.
func (Ref) StartStack ¶
StartStack returns formatted stack where the resource was created.
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource implements tracking a nested resources.
Any child resource must be closed before the parent, otherwise closing the parent returns an error.
Note, in most cases using Ref is preferred as it won't affect performance for production builds.
func RootResource ¶
RootResource returns a root resource tracker.
func (*Resource) Close ¶
Close closes the resource and checks whether all the children have been closed.
func (*Resource) StartStack ¶
StartStack returns formatted stack where the resource was created.