MCPcopy Index your code
hub / github.com/53AI/53AIHub / EncodeStructIDs

Function EncodeStructIDs

api/middleware/response_encoder.go:167–188  ·  view source on GitHub ↗

EncodeStructIDs 编码结构体中的ID字段

(data interface{})

Source from the content-addressed store, hash-verified

165
166// EncodeStructIDs 编码结构体中的ID字段
167func EncodeStructIDs(data interface{}) interface{} {
168 if data == nil {
169 return nil
170 }
171
172 v := reflect.ValueOf(data)
173 if v.Kind() == reflect.Ptr {
174 if v.IsNil() {
175 return nil
176 }
177 v = v.Elem()
178 }
179
180 switch v.Kind() {
181 case reflect.Struct:
182 return encodeStructFields(v)
183 case reflect.Slice:
184 return encodeSliceStructs(v)
185 default:
186 return data
187 }
188}
189
190// encodeStructFields 编码结构体字段
191func encodeStructFields(v reflect.Value) interface{} {

Callers 2

encodeStructFieldsFunction · 0.85
encodeSliceStructsFunction · 0.85

Calls 2

encodeStructFieldsFunction · 0.85
encodeSliceStructsFunction · 0.85

Tested by

no test coverage detected