Register adds module factory function to global registry. name must be unique. Register will panic if module with specified name already exists in registry. You probably want to call this function from func init() of module package.
(name string, factory FuncNewModule)
| 61 | // |
| 62 | // You probably want to call this function from func init() of module package. |
| 63 | func Register(name string, factory FuncNewModule) { |
| 64 | modulesLock.Lock() |
| 65 | defer modulesLock.Unlock() |
| 66 | |
| 67 | if _, ok := modules[name]; ok { |
| 68 | panic("Register: module with specified name is already registered: " + name) |
| 69 | } |
| 70 | |
| 71 | modules[name] = factory |
| 72 | } |
| 73 | |
| 74 | // RegisterDeprecated adds module factory function to global registry. |
| 75 | // |