once.go 120 B

12345678910
  1. package syncx
  2. import "sync"
  3. func Once(fn func()) func() {
  4. once := new(sync.Once)
  5. return func() {
  6. once.Do(fn)
  7. }
  8. }