diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -1,15 +1,26 @@ // Copyright 2025 WIT.COM Inc Licensed GPL 3.0 common config file handling for protobuf defined config files +intended to be super simple so the code you need to write is simple. -By default, the config files are stored as: +Enables Load functions: -~/.config/<argname>/<protoname>.text +// loads ~/.config/myapp/trees.text +cfg := new(MyPB) +err := config.ConfigLoad(cfg, "myapp", "trees") -assumes config files are simple, intended to be edited by hand -by the user and can be exported by protobuf FormatTEXT() +Enables Save functions: -intended to be called by functions that are automatically -generated by 'autogenpb' for protobuf defined config files. +err := cfg.Save() // it automatically knows where to save -If you aren't using .proto defined config files, this package is not for you +### Errors #### + +if errors.Is(err, config.VersionMismatch) { + // protobuf structure changed +} +if errors.Is(err, config.ErrEmpty) { + // config file was empty +} +if errors.Is(err, config.ErrNotExist) { + // config file didn't exist (yes, this is the os.ExistErr) +} |
