diff options
| author | Jeff Carr <[email protected]> | 2025-10-17 01:38:38 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-17 01:38:38 -0500 |
| commit | 5579498720c5c1e0cdf31f97f7ad31dfe9dbf0aa (patch) | |
| tree | f5dea6f7e4bc605358b5bb6ee22ef7c2cffafe37 /README.md | |
| parent | c14367731106c50ff790c5eb4e0cdedc32f0ddd1 (diff) | |
tweaks on config load. more smarters than befores
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) +} |
