-
-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strict parsing #197
Comments
Refactor things a wee bit to add a decoder struct. This doesn't really *do* anything right now, but will be needed to add options, such as "strict mode" in #197 or "extended errors" in #299. Also add DecodeFS() as a companion to DecodeFile() to read from a fs.FS, and since using a reader is the default with NewDecoder() (and was already easy to do before with strings.NewReader()) I marked DecodeReader() as deprecated.
I looked a bit at this, and adding this is possible but non-trivial. I'm also not sure how common this use case necessarily is; certainly most config files I'm familiar with don't need every single key to be set, if there are keys that are required to be set then it's usually only a subset. And should we could all exported struct fields or only those with a And most importantly: this is a use case that can already be solved by checking
Prints:
You can check if Unless there are serious practical problems with this, I think adding this is too much effort for too little benefit. But feel free to comment with more information/use cases and we can look and possibly reopen. |
Is there a way to instruct
toml
to fail if any key=value pair associated to a struct field is not present in the config file?The reason I ask is because
toml.DecodeFile()
does not warn you when a key=value pair is missing, and usingmd.IsDefined()
for each key is not mantainable in large config files.If the feature is not present, would you consider adding it in the future? Having guarantees about the config file completeness is a big deal.
The text was updated successfully, but these errors were encountered: