From 5579498720c5c1e0cdf31f97f7ad31dfe9dbf0aa Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 17 Oct 2025 01:38:38 -0500 Subject: tweaks on config load. more smarters than befores --- README.md | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 29264c2..67dbb17 100644 --- a/README.md +++ b/README.md @@ -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//.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) +} -- cgit v1.2.3