forked from ungerik/go-start
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modifyslicestructvisitor.go
60 lines (45 loc) · 1.68 KB
/
modifyslicestructvisitor.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
package reflection
import "reflect"
// ModifySliceStructVisitor is a StructVisitor that calls its self function
// value in BeginSlice() and ignores all other StructVisitor methos.
// It can be used to modify the length of slices in complex structs.
type ModifySliceStructVisitor func(depth int, v reflect.Value) (reflect.Value, error)
func (self ModifySliceStructVisitor) BeginStruct(depth int, v reflect.Value) error {
return nil
}
func (self ModifySliceStructVisitor) StructField(depth int, v reflect.Value, f reflect.StructField, index int) error {
return nil
}
func (self ModifySliceStructVisitor) EndStruct(depth int, v reflect.Value) error {
return nil
}
func (self ModifySliceStructVisitor) ModifySlice(depth int, v reflect.Value) (reflect.Value, error) {
return self(depth, v)
}
func (self ModifySliceStructVisitor) BeginSlice(depth int, v reflect.Value) error {
return nil
}
func (self ModifySliceStructVisitor) SliceField(depth int, v reflect.Value, index int) error {
return nil
}
func (self ModifySliceStructVisitor) EndSlice(depth int, v reflect.Value) error {
return nil
}
func (self ModifySliceStructVisitor) BeginArray(depth int, v reflect.Value) error {
return nil
}
func (self ModifySliceStructVisitor) ArrayField(depth int, v reflect.Value, index int) error {
return nil
}
func (self ModifySliceStructVisitor) EndArray(depth int, v reflect.Value) error {
return nil
}
func (self ModifySliceStructVisitor) BeginMap(depth int, v reflect.Value) error {
return nil
}
func (self ModifySliceStructVisitor) MapField(depth int, v reflect.Value, key string, index int) error {
return nil
}
func (self ModifySliceStructVisitor) EndMap(depth int, v reflect.Value) error {
return nil
}