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

Function SD

base/redactor_systemdata.go:54–82  ·  view source on GitHub ↗

SD returns a SystemData type for any given value.

(i interface{})

Source from the content-addressed store, hash-verified

52
53// SD returns a SystemData type for any given value.
54func SD(i interface{}) RedactorFunc {
55 switch v := i.(type) {
56 case string:
57 return func() Redactor {
58 return SystemData(v)
59 }
60 case RedactorBuilder:
61 return func() Redactor {
62 return v.BuildRedactor(SD)
63 }
64 case fmt.Stringer:
65 return func() Redactor {
66 return SystemData(v.String())
67 }
68 case []byte:
69 return func() Redactor {
70 return SystemData(string(v))
71 }
72 default:
73 return func() Redactor {
74 valueOf := reflect.ValueOf(i)
75 if valueOf.Kind() == reflect.Slice {
76 return buildRedactorFuncSlice(valueOf, SD)
77 }
78 // Fall back to a slower but safe way of getting a string from any type.
79 return SystemData(fmt.Sprintf("%+v", v))
80 }
81 }
82}

Callers 9

ValidateMethod · 0.92
TestSDFunction · 0.85
GetGoCBv2BucketFunction · 0.85
ListenAndServeHTTPFunction · 0.85
tagPathVarsFunction · 0.85
tagQueryParamsFunction · 0.85
GetBucketFunction · 0.85

Calls 4

SystemDataTypeAlias · 0.85
buildRedactorFuncSliceFunction · 0.85
BuildRedactorMethod · 0.65
StringMethod · 0.65

Tested by 2

TestSDFunction · 0.68