Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
EmptyAppNameError = errors.New("appName is empty")
)
View Source
var (
InvalidLogOutputConfigErr = errors.New("invalid log output configuration: should enable stdout or define an output file")
)
Functions ¶
func InitSetup ¶
func InitSetup(appName string, opts ...OptionFunc) error
InitSetup sets up application default configurations for spf13/viper and slog libraries
Types ¶
type OptionFunc ¶
type OptionFunc func(*SetupOptions)
OptionFunc customization option
func WithConfigFileToBeUsed ¶
func WithConfigFileToBeUsed(file string) OptionFunc
WithConfigFileToBeUsed defines the app configuration file to be used
func WithDefaultCfgFileLocations ¶
func WithDefaultCfgFileLocations(f ...string) OptionFunc
WithDefaultCfgFileLocations defines locations to search for config files
func WithDefaultCfgFileName ¶
func WithDefaultCfgFileName(f string) OptionFunc
WithDefaultCfgFileName defines default config file name
func WithDefaultValues ¶
func WithDefaultValues(vals map[string]any) OptionFunc
WithDefaultValues adds default values to Viper configuration
Default configuration keys:
- Logs configuration
- Log level:
- Log format: `log.format` (accepts `text` or `json`)
- Log level: `log.level` (accepts `info`, `debug`, `warn` or `error`)
- Log output file: `log.output_to_file` (output file path as a string)
- Log to stdout: `log.output_to_stdout` (accepts `true` or `false`)
type SetupOptions ¶
type SetupOptions struct { CfgFilePathToBeUsed string DefaultCfgFileLocations []string DefaultCfgFileName string DefaultValues map[string]any }
func (*SetupOptions) GetDefaultCfgFileLocations ¶
func (o *SetupOptions) GetDefaultCfgFileLocations(appName string) []string
func (*SetupOptions) GetDefaultCfgFileName ¶
func (o *SetupOptions) GetDefaultCfgFileName() string
func (*SetupOptions) GetDefaultValues ¶
func (o *SetupOptions) GetDefaultValues() map[string]any
Click to show internal directories.
Click to hide internal directories.