MCPcopy Index your code
hub / github.com/koding/kite / fields

Method fields

dnode/scrub.go:71–103  ·  view source on GitHub ↗

fields walks over a structure and scrubs its fields.

(rv reflect.Value, path Path, callbacks map[string]Path)

Source from the content-addressed store, hash-verified

69
70// fields walks over a structure and scrubs its fields.
71func (s *Scrubber) fields(rv reflect.Value, path Path, callbacks map[string]Path) {
72 for i := 0; i < rv.NumField(); i++ {
73 sf := rv.Type().Field(i)
74 if sf.PkgPath != "" && !sf.Anonymous { // unexported.
75 continue
76 }
77
78 // dnode uses JSON package tags for field naming so we need to
79 // discard their comma-separated options.
80 tag := sf.Tag.Get("json")
81 if idx := strings.Index(tag, ","); idx != -1 {
82 tag = tag[:idx]
83 }
84 if tag == "-" {
85 continue
86 }
87 // do not collect callbacks for "-" tagged fields.
88 if skip := sf.Tag.Get("dnode"); skip == "-" {
89 continue
90 }
91
92 var name = tag
93 if name == "" {
94 name = sf.Name
95 }
96
97 if sf.Anonymous {
98 s.collect(rv.Field(i), path, callbacks)
99 } else {
100 s.collect(rv.Field(i), append(path, name), callbacks)
101 }
102 }
103}
104
105// methods walks over a structure and scrubs its exported methods.
106func (s *Scrubber) methods(rv reflect.Value, path Path, callbacks map[string]Path) {

Callers 1

collectMethod · 0.95

Calls 2

collectMethod · 0.95
GetMethod · 0.65

Tested by

no test coverage detected