gitee.com/zhongguo168a/gocodes@v0.0.0-20230609140523-e1828349603f/datax/modifyx/modify_type.go (about) 1 package modifyx 2 3 import "sync" 4 5 var ( 6 typeCreator = map[string]func(object IObject) IObject{} 7 mutex sync.RWMutex 8 ) 9 10 func RegisterType(name string, creator func(object IObject) IObject) { 11 mutex.Lock() 12 typeCreator[name] = creator 13 mutex.Unlock() 14 } 15 16 func getType(name string) func(object IObject) IObject { 17 mutex.RLock() 18 creator := typeCreator[name] 19 mutex.RUnlock() 20 return creator 21 }