mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-13 09:50:00 +08:00
update:Use the official sync.OnceFunc (#4840)
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
package syncx
|
||||
|
||||
import "sync"
|
||||
|
||||
// Once returns a func that guarantees fn can only called once.
|
||||
func Once(fn func()) func() {
|
||||
once := new(sync.Once)
|
||||
return func() {
|
||||
once.Do(fn)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user