diff options
| author | Jeff Carr <[email protected]> | 2025-10-14 00:49:35 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-14 00:49:35 -0500 |
| commit | 96378c70293b7367f43e630a8d334c19f701b4db (patch) | |
| tree | 8460d772f069a3e7e30e1bd29786ce23afa32e8e | |
| parent | fc17dc394aedbc5fd636676202bad40c1f98c1de (diff) | |
make config.Set(key, value)v0.0.22
| -rw-r--r-- | errors.go | 5 | ||||
| -rw-r--r-- | flags.go | 19 | ||||
| -rw-r--r-- | init.go | 4 |
3 files changed, 17 insertions, 11 deletions
diff --git a/errors.go b/errors.go new file mode 100644 index 0000000..807386d --- /dev/null +++ b/errors.go @@ -0,0 +1,5 @@ +package config + +import "errors" + +var NotInitialized error = errors.New("your application config not initialized") @@ -11,13 +11,18 @@ func Get(flag string) string { return found.Value } -func GetError(flag string) error { - return nil -} - -func Set(flag string) { -} +func Set(key string, newValue string) error { + if configPB == nil { + return NotInitialized + } + found := configPB.FindByKey(key) + if found != nil { + found.Value = newValue + } -func SetError(flag string) error { + newvar := new(Config) + newvar.Key = key + newvar.Value = newValue + configPB.Append(newvar) return nil } @@ -66,10 +66,6 @@ func makeNewConfigFile(appname string) error { newvar.Value = "protobufs are neat" configPB.Clone(newvar) - newvar.Key = "Verbose" - newvar.Value = "true" - configPB.Clone(newvar) - // writes the config file to disk err = Save() return err |
