-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.go
66 lines (53 loc) · 1.24 KB
/
module.go
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package application
import (
"github.com/starter-go/application/resources"
)
const (
theModuleName = "github.com/starter-go/application"
theModuleVersion = "v0.9.25"
theModuleRevision = 9
)
////////////////////////////////////////////////////////////////////////////////
// Module 表示一个 Starter 模块
type Module interface {
Name() string
Version() string
Revision() int
Dependencies() []Module
Resources() resources.Table
RegisterComponents(r ComponentRegistry) error
}
////////////////////////////////////////////////////////////////////////////////
type myModule struct {
name string
version string
revision int
deps []Module
res resources.Table
registry ComponentRegistryFunc
}
func (inst *myModule) _Impl() Module {
return inst
}
func (inst *myModule) Name() string {
return inst.name
}
func (inst *myModule) Version() string {
return inst.version
}
func (inst *myModule) Revision() int {
return inst.revision
}
func (inst *myModule) Dependencies() []Module {
return inst.deps
}
func (inst *myModule) Resources() resources.Table {
return inst.res
}
func (inst *myModule) RegisterComponents(r ComponentRegistry) error {
fn := inst.registry
if fn == nil || r == nil {
return nil
}
return fn(r)
}