multiconfig icon indicating copy to clipboard operation
multiconfig copied to clipboard

Default values for slices of embedded structs are not working

Open ajanata opened this issue 7 years ago • 2 comments

Similar to #13, but the problem is if you have a slice of a struct, the default values aren't getting applied. I took a stab at trying to figure out what's going on here, but didn't really get anywhere productive.

ajanata avatar Mar 16 '18 19:03 ajanata

Hey @ajanata could you please share an example config/struct that fails?

cihangir avatar Mar 18 '18 19:03 cihangir

Hi @cihangir,

I've made a branch that contains a test case for this: https://github.com/ajanata/multiconfig/commit/f9657feea2708ee9ee37ca8bb070879105603808

It fails as such:

defaultslice_test.go:90: Test file defaultslice.toml, NestedField value is wrong: , want: nested
defaultslice_test.go:90: Test file defaultslice.json, NestedField value is wrong: , want: nested
defaultslice_test.go:90: Test file defaultslice.yaml, NestedField value is wrong: , want: nested

I also used the same struct directly, not as a slice, and the default value tag works as intended there (and is also tested).

ajanata avatar Mar 19 '18 22:03 ajanata