go-zero/core/syncx/once.go
2020-07-26 17:09:05 +08:00

11 lines
120 B
Go

package syncx
import "sync"
func Once(fn func()) func() {
once := new(sync.Once)
return func() {
once.Do(fn)
}
}