MCPcopy
hub / github.com/tailscale/tailscale / Defer

Method Defer

types/lazy/deferred.go:47–55  ·  view source on GitHub ↗

Defer adds a function to be called when [DeferredInit.Do] is called for the first time. It returns true on success, or false if [DeferredInit.Do] has already been called.

(f func() error)

Source from the content-addressed store, hash-verified

45// is called for the first time. It returns true on success,
46// or false if [DeferredInit.Do] has already been called.
47func (d *DeferredFuncs) Defer(f func() error) bool {
48 d.m.Lock()
49 defer d.m.Unlock()
50 if d.err.Load() != nil {
51 return false
52 }
53 d.funcs = append(d.funcs, f)
54 return true
55}
56
57// MustDefer is like [DeferredFuncs.Defer], but panics
58// if [DeferredInit.Do] has already been called.

Callers 4

MustDeferMethod · 0.95
ExampleDeferredInitFunction · 0.80
TestDeferredInitFunction · 0.80
TestDeferAfterDoFunction · 0.80

Calls 3

LockMethod · 0.65
UnlockMethod · 0.65
LoadMethod · 0.65

Tested by 3

ExampleDeferredInitFunction · 0.64
TestDeferredInitFunction · 0.64
TestDeferAfterDoFunction · 0.64