Documentation
¶
Index ¶
Constants ¶
View Source
const ( NewFileBehaviorReject newFileBehavior = iota // If the file doesn't exist, return an error NewFileBehaviorCreateAndReject // If the file doesn't exist, create it with any defaults, but still return an error NewFileBehaviorCreateAndTry // If the file doesn't exist, create it with any defaults, and then try to load it (which may still error if required fields are missing) )
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶
LoadConfig loads a TOML config file into a struct of type ConfigType.
func MustLoadConfig ¶
MustLoadConfig is a helper that panics if LoadConfig returns an error. Useful for cases where you want to load a config at startup and want the program to fail fast if the config is invalid.
Types ¶
type Option ¶
type Option func(*_options)
func WithIndentSpaces ¶
Set the indentation spaces for the generated TOML file (default: 4)
func WithNewFileBehavior ¶
func WithNewFileBehavior(behavior newFileBehavior) Option
Set the behavior for when the config file doesn't exist (default: Reject)
Click to show internal directories.
Click to hide internal directories.