MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / countFields

Function countFields

rest/config_flags_test.go:158–173  ·  view source on GitHub ↗
(cfg interface{})

Source from the content-addressed store, hash-verified

156}
157
158func countFields(cfg interface{}) (fields int) {
159 rField := reflect.ValueOf(cfg)
160 if rField.Kind() == reflect.Ptr {
161 rField = rField.Elem()
162 }
163 if rField.Kind() != reflect.Struct {
164 return 1
165 }
166 for i := 0; i < rField.NumField(); i++ {
167 jsonTag := reflect.TypeOf(rField.Interface()).Field(i).Tag.Get("json")
168 if !strings.HasPrefix(jsonTag, "-") { // could be -,omitempty therefore prefix check
169 fields += countFields(rField.Field(i).Interface())
170 }
171 }
172 return fields
173}
174
175// TestDisabledFlagsErrorAndDoNotMutateConfig ensures disabled flags error and values are not wired into StartupConfig.
176func TestDisabledFlagsErrorAndDoNotMutateConfig(t *testing.T) {

Callers 1

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected