A customizable configuration library that supports multiple files and formats.
- Make support for multiple configuration files and sources easy to use and extend.
- Simplify tracing the origin of a configuration value.
- Favor user customization options over building everything in, keeping dependencies to a minimum.
- Embrace patterns that make using other powerful libraries (kong, fx, etc) simple.
This package has not yet released to 1.x yet, so APIs are subject to change for a bit longer.
After v1 is released, SemVer will be followed.
go get github.com/goschtalt/goschtalt
Instead of trying to build everything in, goschtalt tries to only build in what is absolutely necessary and favor extensions. This enables a diversity of ecosystem while not bloating your code with a bunch of dependencies.
The following are popular goschtalt extensions:
- Name nomenclature converter https://github.com/goschtalt/casemapper
- Environment variable decoder https://github.com/goschtalt/env-decoder
- JSON file type decoder https://github.com/goschtalt/json-decoder
- Properties file type Decoder https://github.com/goschtalt/properties-decoder
- YAML file type decoder https://github.com/goschtalt/yaml-decoder
- YAML file type encoder https://github.com/goschtalt/yaml-encoder
Coming soon.
There are only two production dependencies in the core goschtalt code beyond the go standard library. The rest are testing dependencies.
Production dependencies:
This is more detailed overview of how the configuration is compiled.
stateDiagram-v2
direction TB
state Gather_Inputs {
direction TB
AddBuffer() --> New()
AddFile() --> New()
AddValue(AsDefault()) --> New()
}
state Sequence {
direction TB
Defaults:Defaults by order added.
Records:Records sorted using record label.
ex:Expand instructions by order added.
Defaults --> Records
Records --> ex
}
state Compile {
calc:Calculate configuration<br/>tree at this point.
eval:Apply all Expand()<br/>and ExpandEnv()<br/>to configuration<br/>tree in order.
fetch:Call any user<br/>provided funcs with<br/>configuration tree.
next:Next<br/>Configuration<br/>Tree Part
merge:Merge the new<br/>configuration tree part<br/>with the current tree
Empty:Empty<br/>Configuration<br/>Tree
Empty --> calc
calc --> eval:If a user func<br/>is provided
calc --> next:If no user func<br/>is provided
eval --> fetch
fetch --> next
next --> merge
merge --> calc
}
state Expand {
exp:Apply all Expand()<br/>and ExpandEnv()<br/>to configuration<br/>tree in order.
}
state Active {
active:Active Configuration
unmarshal:Unmarshal()
active --> unmarshal
unmarshal --> active
}
New() --> Sequence
Sequence --> Compile
Compile --> Expand
Expand --> Active
Active --> Sequence:With() or Compile() called<br/>resequences the lists and<br/>recalculates the <br/>configuration tree.