Documentation ¶
Index ¶
Constants ¶
const ( AppEnvProd = "prod" // prod environment AppEnvDev = "dev" // dev environment AppEnvTest = "test" // test environment DefaultAppName = "app" // default application name DefaultAppVersion = "unknown" // default application version )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config allows to access the application configuration, and inherits of all Viper features.
func (*Config) AppDebug ¶
AppDebug returns if the application debug mode is enabled (from config field app.debug or env var APP_DEBUG).
func (*Config) AppEnv ¶
AppEnv returns the configured application environment (from config field app.env or env var APP_ENV).
func (*Config) AppName ¶
AppName returns the configured application name (from config field app.name or env var APP_NAME).
func (*Config) AppVersion ¶
AppVersion returns the configured application version (from config field app.version or env var APP_VERSION).
type ConfigFactory ¶
type ConfigFactory interface {
Create(options ...ConfigOption) (*Config, error)
}
ConfigFactory is the interface for Config factories.
func NewDefaultConfigFactory ¶
func NewDefaultConfigFactory() ConfigFactory
NewDefaultConfigFactory returns a DefaultConfigFactory, implementing ConfigFactory.
type ConfigOption ¶
type ConfigOption func(o *Options)
ConfigOption are functional options for the ConfigFactory implementations.
func WithFileName ¶
func WithFileName(n string) ConfigOption
WithFileName is used to specify the file base name (without extension) of the config file to load.
func WithFilePaths ¶
func WithFilePaths(p ...string) ConfigOption
WithFilePaths is used to specify the list of file paths to lookup config files to load.
type DefaultConfigFactory ¶
type DefaultConfigFactory struct{}
DefaultConfigFactory is the default ConfigFactory implementation.
func (*DefaultConfigFactory) Create ¶
func (f *DefaultConfigFactory) Create(options ...ConfigOption) (*Config, error)
Create returns a new Config, and accepts a list of ConfigOption. For example:
var cfg, _ = config.NewDefaultConfigFactory().Create()
is equivalent to:
var cfg, _ = config.NewDefaultConfigFactory().Create( config.WithFileName("config"), // config files base name config.WithFilePaths(".", "./configs"), // config files lookup paths )
type Options ¶
Options are options for the ConfigFactory implementations.
func DefaultConfigOptions ¶
func DefaultConfigOptions() Options
DefaultConfigOptions are the default options used in the DefaultConfigFactory.