Is there a way to overwrite existing values with ReflectFrom in go-ini?

38 Views Asked by At

I'm using ReflectFrom to load data from a struct into an ini.File, with AllowShadows set to true on the file, this works, but leaves me with duplicate values. With AllowShadows set to false, ReflectFrom has no effect, it does not overwrite the data that already exists in gusIni. I need to load from the file because it could contain data that the struct does not.

gusIni, err := ini.LoadSources(iniOpts, filePathToLoadFrom)
err = gusIni.ReflectFrom(&s.GameUserSettings)
if err != nil {
    return err
}

where iniOpts is

var iniOpts = ini.LoadOptions{
    AllowShadows: false,
}

What I've tried:

  • AllowShadows: true, unfortunately just creates duplicate entries
  • AllowShadows: true & AllowDuplicateShadowValues: false, picks the last mention as the correct entry, which in my case is the wrong value

I thought that ReflectFrom would overwrite the existing values, but it doesn't.

What can I do to solve this?

0

There are 0 best solutions below