Re:Go JSON/v2 Package
by sureglymop on Saturday October 07, 2023 @03:07AM
(#37799661)
Does anyone know if there is a good "config validation" package in go?
I want to read in a json config file from the user, validate it with a schema that even checks for missing keys or keys that shouldn't be in the file, then if there are errors I want to print to the user the exact line of the file that is the problem.
The assumption is that the user will misconfigure something and should thus be informed.
[ Parent
| on HN ]
Re:Go JSON/v2 Package
by philosopher1234 on Saturday October 07, 2023 @04:15AM
(#37799975)
Check out cue lang
Re:Go JSON/v2 Package
by c2xlZXB5Cg1 on Saturday October 07, 2023 @05:57AM
(#37800428)
How does one grok cuelang?
Asking for a friend.
validator has worked well for me, but it doesn't operate on files, rather it validates the structs after unmarshaling.
Re:Go JSON/v2 Package
by sureglymop on Saturday October 07, 2023 @01:56PM
(#37803959)
I am using validator now and it's okay. I did have to write some custom validators and it wasn't too well documented.
Unfortunately it's a bit hard to generate the right error messages for the user to see exactly where the misconfiguration is.