general.go 449 字节
Newer Older
E
eoLinker API Management 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
package general

type InitFunc func() error

var (
	_initFunc  []InitFunc
	_laterFunc []InitFunc
)

func RegeditInit(fn InitFunc) {

	_initFunc = append(_initFunc, fn)
}
func General() error {
	for _, fn := range _initFunc {
		if err := fn(); err != nil {
			return err
		}
	}
	for _, fn := range _laterFunc {
		if err := fn(); err != nil {
			return err
		}
	}
	return nil
}

func RegeditLater(fn InitFunc) {
	_laterFunc = append(_laterFunc, fn)
}