| 259 | } |
| 260 | |
| 261 | func (y appendHandler) write(file *os.File, configs []ExportedConfig, confMap map[string]interface{}) error { |
| 262 | out: |
| 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 | |
| 290 | type rewriteHandler struct { |
| 291 | codec contract.Codec |