blob: 67dbb1736465808e5d085ddcbf8f2d74c4604a1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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.
Enables Load functions:
// loads ~/.config/myapp/trees.text
cfg := new(MyPB)
err := config.ConfigLoad(cfg, "myapp", "trees")
Enables Save functions:
err := cfg.Save() // it automatically knows where to save
### 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)
}
|