mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-14 20:41:15 +08:00
19 lines
250 B
Go
19 lines
250 B
Go
package commit
|
|
|
|
import "sync"
|
|
|
|
var (
|
|
lock sync.Mutex
|
|
onceMap = make(map[string]struct{})
|
|
)
|
|
|
|
func onceMigrate(key string, f func()) {
|
|
lock.Lock()
|
|
defer lock.Unlock()
|
|
if _, ok := onceMap[key]; ok {
|
|
return
|
|
}
|
|
f()
|
|
onceMap[key] = struct{}{}
|
|
}
|