Documentation
¶
Overview ¶
Package viperconfig provides a generic, tag-based configuration loading and validation system built on top of Viper. It supports loading from YAML files and environment variables with automatic validation using struct tags.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LoadOptions ¶
type LoadOptions struct {
// contains filtered or unexported fields
}
LoadOptions configures how configuration is loaded
type Option ¶
type Option func(*LoadOptions)
Option is a functional option for configuring LoadOptions
func WithConfigName ¶
WithConfigName sets the config file name without extension (default: "config")
func WithConfigPaths ¶
WithConfigPaths sets the paths to search for config file Replaces default paths entirely
func WithConfigType ¶
WithConfigType sets the config file type (default: "yaml") Supported: yaml, json, toml, etc.
func WithEnvPrefix ¶
WithEnvPrefix sets the environment variable prefix (default: "APP") Environment variables will be UPPERCASE(prefix)_KEY_NAME
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator provides configuration validation functionality
func NewValidator ¶
NewValidator creates a new Validator instance
func (*Validator) LoadAndValidate ¶
LoadAndValidate loads configuration from Viper into the provided struct and validates it The struct must have mapstructure tags for Viper unmarshaling
Supported tags:
- mapstructure:"key_name" - maps to configuration key
- optional:"true" - field can be empty (not required)
- default:"value" - default value if not set
- validate:"rule1,rule2" - validation rules (nonempty, positive, url, hostname)
By default, all fields are required unless marked optional or have a default value.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package grpcclients provides a gRPC dial helper that tries a list of URLs in order and returns a connection to the first one whose grpc_health_v1 Check succeeds.
|
Package grpcclients provides a gRPC dial helper that tries a list of URLs in order and returns a connection to the first one whose grpc_health_v1 Check succeeds. |