-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
42 lines (35 loc) · 813 Bytes
/
main.go
File metadata and controls
42 lines (35 loc) · 813 Bytes
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
package main
import (
"errors"
"fmt"
"github.com/pubgo/dix/v2/dixglobal"
)
func main() {
defer func() {
if r := recover(); r != nil {
fmt.Printf("panic: %v\n", r)
}
}()
dixglobal.Provide(func() map[string]error {
return map[string]error{
"": errors.New("default msg"),
"hello": errors.New("hello"),
}
})
dixglobal.Provide(func() map[string]error {
return map[string]error{
"hello": errors.New("hello1"),
}
})
dixglobal.Inject(func(err error, errs map[string]error, errMapList map[string][]error) {
fmt.Println(err.Error())
fmt.Println(errs)
fmt.Println(errMapList)
})
type param struct {
ErrMap map[string]error
ErrMapList map[string][]error
}
fmt.Println(dixglobal.Inject(new(param)).ErrMap)
fmt.Println(dixglobal.Inject(new(param)).ErrMapList)
}