Replies: 1 comment
-
Hi! Sorry for the delay. I don't think you have a way to do this easily at the moment. Your best option as you mentioned is to create a full structure. Otherwise maybe you can build something on top of the parser API, but that's a very low level component which will probably make you rebuild quite a bit of the unmarshaler logic. I wonder if it's something that other encoding libraries (json, yaml, etc) have solved in Go. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've been using version 2 and it works very well. Thanks.
But I do have a question on the options I have to do something not mentioned in its documentation:
Imagine this TOML file:
and these 2 structures in go:
Is it possible for me to execute Unmarshal twice to fill both structs? When running for
Cfg1
it works, but I can not find a way to forceCfg2
to understand its root iss4
block inside the TOML.Yes, I know I can create a single struct that covers the whole TOML struct, and then read its sub-structures. That's how I have it now. But in reality my TOML is huge and I have to broke it into 5 unrelated big structures to feed 5 different services of my server. Having a single central and huge structure looks "ugly".
Just asking myself if I am missing something that would allow for the cleaner approach of selecting a root point when Unmarshaling.
Beta Was this translation helpful? Give feedback.
All reactions