mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 01:48:22 +08:00
eb16882282
* fix(bootstrap module): add bootstrap module to meet future function * Fix readme * Fix panic because log.logger is nil * fix import --------- Co-authored-by: zbhan <zbhan@freewheel.tv>
23 lines
439 B
Go
23 lines
439 B
Go
package bootstrap
|
|
|
|
import "nofx/config"
|
|
|
|
type InitHook func(config *config.Config) error
|
|
|
|
var InitHooks []InitHook
|
|
|
|
// RegisterInitHook 注册初始化钩子
|
|
func RegisterInitHook(hook InitHook) {
|
|
InitHooks = append(InitHooks, hook)
|
|
}
|
|
|
|
// RunInitHooks 运行所有注册的初始化钩子
|
|
func RunInitHooks(c *config.Config) error {
|
|
for _, hookF := range InitHooks {
|
|
if err := hookF(c); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|