config icon indicating copy to clipboard operation
config copied to clipboard

Add support of Map

Open DenisPalnitsky opened this issue 2 years ago • 6 comments

DenisPalnitsky avatar Oct 08 '22 13:10 DenisPalnitsky

Perhaps updating the dependency will be enough github.com/iamolegga/enviper v1.4.0 to v1.4.2

d-enk avatar Dec 01 '23 11:12 d-enk

That did not work for me. I believe because of https://github.com/iamolegga/enviper/blob/76a709d405c3d4aaafcea174dda051b8a39c5bcd/enviper_test.go#L90

DenisPalnitsky avatar Dec 01 '23 16:12 DenisPalnitsky

Fix in v1.4.2 allows to read from a file like this

Map:
 'key1': 'val1'
 'key2': 'val2'
var Config struct {
  Map  map[string]string
}


config.NewConfReader("config").Read(&Config)

d-enk avatar Dec 01 '23 16:12 d-enk

Got it. It supports only config files, right? Env vars are not yet supported I suppose.

I tried env vars like here https://github.com/num30/config/blob/ddeb8abccdae0d1b0ae1dada9490b1f140fbb2b6/config_test.go#L423 and it does not init the map. Also, I tried the code snippet from documentation and it did not init the map either.

DenisPalnitsky avatar Dec 01 '23 17:12 DenisPalnitsky

Honestly, I just now saw such syntax there) I needed to make this case work

d-enk avatar Dec 01 '23 17:12 d-enk

I got that syntax from Readme. It would be fine to have something like TESTMAP="a:1,b:2"

DenisPalnitsky avatar Dec 01 '23 17:12 DenisPalnitsky