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.
I haven’t come across anything specifically for this use case, but you could probably achieve this using either json-schema or by using struct tags from the go-playground/validator package.
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.