MCPcopy
hub / github.com/tailscale/tailscale / Do

Method Do

types/lazy/deferred.go:72–78  ·  view source on GitHub ↗

Do calls previously deferred init functions if it is being called for the first time on this instance of [DeferredInit]. It stops and returns an error if any init function returns an error. It is safe for concurrent use, and the deferred init is guaranteed to have been completed, either successfull

()

Source from the content-addressed store, hash-verified

70// to have been completed, either successfully or with an error,
71// when Do() returns.
72func (d *DeferredInit) Do() error {
73 err := d.err.Load()
74 if err == nil {
75 err = d.doSlow()
76 }
77 return *err
78}
79
80func (d *DeferredInit) doSlow() (err *error) {
81 d.m.Lock()

Callers 4

ExampleDeferredInitFunction · 0.95
TestDeferredInitFunction · 0.95
TestDeferredErrFunction · 0.95
TestDeferAfterDoFunction · 0.95

Calls 2

doSlowMethod · 0.95
LoadMethod · 0.65

Tested by 4

ExampleDeferredInitFunction · 0.76
TestDeferredInitFunction · 0.76
TestDeferredErrFunction · 0.76
TestDeferAfterDoFunction · 0.76