TwiN / deepmerge

Go library for deep merging YAML or JSON
MIT License
6 stars 1 forks source link

Config option to not override with empty values #5

Open sigurdblueface opened 4 weeks ago

sigurdblueface commented 4 weeks ago

Describe the feature request

so imagine we have a 'base' yaml file

app:
  name: base
  vault: 
    url: url
    path: path

we have an 'override' yaml file

app:
  name: api
  vault: {}

we're unmarshalling these into map[string]interface{}

on merge

err = deepmerge.DeepMerge(<map with base app>, <map with override app>, mergeConfig)
if err != nil {
  return err
}

we have as a result:

app:
  name: api
  vault: {}

it seems pretty logical indeed, but It would be great to have that behaviour configurable.

Why do you personally want this feature to be implemented?

in order not to write omitempty to every yaml structure

How long have you been using this project?

No response

Additional information

No response

TwiN commented 2 weeks ago

Just to make sure I understand, you'd want a way to have the 2nd yaml file override the 1st in instances where json objects are explicitly set to {}?

I'm not against the idea