-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
51 lines (48 loc) · 893 Bytes
/
main.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
package main
import (
. "github.com/vlorc/gioc"
. "github.com/vlorc/gioc/module"
. "github.com/vlorc/gioc/module/operation"
"github.com/vlorc/gioc/types"
)
// config.go
var ConfigModule = NewModuleFactory(
Condition(
HavingValue(Equal("PRODUCT"), types.StringType, "ENV"),
Export(
Mapping(map[string]interface{}{
"id": 1,
"name": "product",
}),
), Bootstrap(func() {
println("product")
}),
),
Condition(
Not(HavingValue(Equal("PRODUCT"), types.StringType, "ENV")),
Export(
Mapping(map[string]interface{}{
"id": 2,
"name": "debug",
}),
),
Bootstrap(func() {
println("debug")
}),
),
)
// main.go
func main() {
NewRootModule(
Declare(
Instance("DEBUG"), Id("ENV"),
),
Import(ConfigModule),
Bootstrap(func(param struct {
id int
name string
}) {
println("id: ", param.id, " name: ", param.name)
}),
)
}