dependency

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package dependency 依赖管理,可以保证各个模块能按顺序初始化依赖项。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependency

type Dependency struct {
	// contains filtered or unexported fields
}

Dependency 模块管理工具,管理模块的初始化顺序

func New

func New() *Dependency

New 声明一个 Dependency 实例

func (*Dependency) Add

func (dep *Dependency) Add(name string, init InitFunc, deps ...string) error

Add 添加一个新的模块。

name 为模块的名称; init 为模块的初始化函数; deps 为模块的依赖模块,依赖模块可以后于当前模块注册,但必须要存在。

func (*Dependency) Init

func (dep *Dependency) Init() error

Init 对所有的模块进行初始化操作,会进行依赖检测。 若模块初始化出错,则会中断并返回出错信息。

type InitFunc

type InitFunc func() error

InitFunc 模块的初始化函数。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL