github.com/aykevl/tinygo@v0.5.0/src/sync/once.go (about) 1 package sync 2 3 type Once struct { 4 done bool 5 m Mutex 6 } 7 8 func (o *Once) Do(f func()) { 9 o.m.Lock() 10 defer o.m.Unlock() 11 if o.done { 12 return 13 } 14 o.done = true 15 f() 16 }