Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAppConfigModule ¶
func NewAppConfigModule(opts ...AppConfigOption) fx.Option
NewAppConfigModule creates an fx module for application configuration. By default, loads from environment variables (APP_ENV, APP_SERVICE_NAME, APP_SERVICE_VERSION). Use WithAppConfig for static config (useful for tests).
func NewDotEnvModule ¶ added in v0.4.3
func NewDotEnvModule(opts ...DotEnvOption) fx.Option
NewDotEnvModule loads environment variables from a .env file. By default, loads from ".env" in the current directory. Loading happens synchronously when the module is created.
func NewViperModule ¶
func NewViperModule(opts ...ViperOption) fx.Option
NewViperModule creates an fx module for Viper configuration. By default, resolves config path from CONFIG_FILE environment variable. If env var is not set, creates an empty Viper instance. Use WithConfigPath to override with a direct path. Use WithoutConfigFile to disable config file loading.
Types ¶
type AppConfig ¶
type AppConfig struct {
ServiceName string
ServiceVersion string
// Environment is the deployment environment (e.g., "local", "staging", "pro")
Environment string
IsKubernetes bool
}
AppConfig represents the core application metadata.
type AppConfigOption ¶ added in v0.4.3
type AppConfigOption func(*appConfigOptions)
AppConfigOption is a functional option for configuring the AppConfig module.
func WithAppConfig ¶ added in v0.4.3
func WithAppConfig(cfg AppConfig) AppConfigOption
WithAppConfig provides a static AppConfig (useful for tests).
type DotEnvOption ¶ added in v0.4.3
type DotEnvOption func(*dotenvConfig)
DotEnvOption is a functional option for configuring the dotenv module.
func WithDotEnvPath ¶ added in v0.4.3
func WithDotEnvPath(path string) DotEnvOption
WithDotEnvPath sets a custom path to the .env file.
type FilePath ¶ added in v0.4.3
type FilePath string
FilePath represents the path to a configuration file. Empty string means no config file will be loaded.
type ViperOption ¶ added in v0.4.3
type ViperOption func(*viperConfig)
ViperOption is a functional option for configuring the Viper module.
func WithConfigPath ¶ added in v0.4.3
func WithConfigPath(path string) ViperOption
WithConfigPath sets a direct path to the configuration file. Overrides the default behavior of resolving from environment variables.
func WithoutConfigFile ¶ added in v0.4.3
func WithoutConfigFile() ViperOption
WithoutConfigFile disables loading of any config file. Viper will still be available for DI but with no file-based configuration.