-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmethod.go
More file actions
42 lines (33 loc) · 849 Bytes
/
method.go
File metadata and controls
42 lines (33 loc) · 849 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 api
import (
"fmt"
"reflect"
)
type method struct {
method reflect.Method
// Many Types could point to the same dependencie
// It could occour couse could have any number of Interfaces
// that could be satisfied by a single dependency
dependencies dependencies
outName []string
}
func newMethod(m reflect.Method, r *resource) (*method, error) {
//log.Println("Creating Method", m.Name, m.Type)
ds, err := newDependencies(m, r)
if err != nil {
return nil, err
}
h := &method{
method: m,
dependencies: ds,
outName: make([]string, m.Type.NumOut()),
}
// Caching the Output Resources name
for i := 0; i < m.Type.NumOut(); i++ {
h.outName[i] = elemOfType(m.Type.Out(i)).Name()
}
return h, nil
}
func (h *method) String() string {
return fmt.Sprintf("[%s] %s", h.method.Name, h.method.Type)
}