MCPcopy Create free account
hub / github.com/DoNewsCode/core / write

Method write

config/module.go:261–288  ·  view source on GitHub ↗
(file *os.File, configs []ExportedConfig, confMap map[string]interface{})

Source from the content-addressed store, hash-verified

259}
260
261func (y appendHandler) write(file *os.File, configs []ExportedConfig, confMap map[string]interface{}) error {
262out:
263 for i, config := range configs {
264 for k := range config.Data {
265 if _, ok := confMap[k]; ok {
266 continue out
267 }
268 }
269 if i != 0 {
270 fmt.Fprintln(file, "")
271 }
272 bytes, err := y.codec.Marshal(config.Data)
273 if err != nil {
274 return err
275 }
276 if config.Comment != "" {
277 _, err = fmt.Fprintln(file, "# "+config.Comment)
278 if err != nil {
279 return err
280 }
281 }
282 _, err = file.Write(bytes)
283 if err != nil {
284 return err
285 }
286 }
287 return nil
288}
289
290type rewriteHandler struct {
291 codec contract.Codec

Callers

nothing calls this directly

Calls 2

MarshalMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected