traefik / paerser

Loads configuration from many sources
Apache License 2.0
54 stars 18 forks source link

feat: handles any with RawValue #17

Open juliens opened 10 months ago

juliens commented 10 months ago

This PR handles field any as RawValue.

it means that if you have for example something like

"foo.bar.baz"="fuu"
"foo.bar.huu"="hii"

and you try to handle it with a struct like

struct {
  foo any
}

This will do something like this:

{
   foo: map[string]any{
      "bar": map[string]any{
         "baz": "fuu",
         "huu": "hii",
      } 
   }
}
juliens commented 10 months ago

I need to have any in the context where I don't know the real struct behind the data. In this context, I think that we were using map[string]interface{} but with this, it's not possible to put a string directly in this field.

To seperate any and real interface, may be I can use NumMethod?

https://go.dev/play/p/Jt7nSJ6veOO