MCPcopy
hub / github.com/eolinker/goku_lite / Read

Method Read

console/module/config-log/log.go:228–269  ·  view source on GitHub ↗
(ent *entity.LogConfig)

Source from the content-addressed store, hash-verified

226 }
227}
228func (c *AccessConfig) Read(ent *entity.LogConfig) {
229
230 c.Name = ent.Name
231 c.Enable = ent.Enable == 1
232 c.Dir = ent.Dir
233 c.File = ent.File
234 c.Period = ent.Period
235 c.Expire = ent.Expire
236 fields := make([]*AccessField, 0, access_field.Size())
237 e := json.Unmarshal([]byte(ent.Fields), &fields)
238 if e != nil {
239 c.InitFields()
240 return
241 }
242
243 all := access_field.CopyKey()
244
245 fieldsTmp := make([]*AccessField, 0, access_field.Size())
246 // 筛选有效的字段
247 for _, field := range fields {
248 if desc, has := all[field.Name]; has {
249 field.Desc = desc
250 fieldsTmp = append(fieldsTmp, field)
251 delete(all, field.Name)
252 }
253 }
254
255 // 如果有新增的字段,按默认顺序拼接到末尾
256 for _, value := range access_field.All() {
257 if _, has := all[value.Key()]; has {
258 field := &AccessField{
259 Name: value.Key(),
260 Select: false,
261 Desc: value.Info(),
262 }
263 fieldsTmp = append(fieldsTmp, field)
264 }
265 }
266
267 c.Fields = fieldsTmp
268
269}

Callers

nothing calls this directly

Calls 5

InitFieldsMethod · 0.95
appendFunction · 0.85
deleteFunction · 0.85
InfoMethod · 0.80
KeyMethod · 0.65

Tested by

no test coverage detected