config – Environment Configuration LoaderThe config package uses Viper to load application settings from .env files and environment variables. It centralizes important runtime configuration like database URLs, server addresses, and secret keys.
Configtype Config struct {
DBSource string
ServerAddress string
TokenSymmetricKey string
AccessTokenDuration time.Duration
GeminiAPIKey string
}
Represents application-wide configuration values loaded from an environment file.
LoadConfigfunc LoadConfig(path string) (Config, error)
Loads config values from a file named app.env located in the given directory path. Uses viper to also pull values from environment variables.
app.env in the specified path.Config struct.app.env fileDB_SOURCE=postgres://user:pass@localhost:5432/dbname
SERVER_ADDRESS=0.0.0.0:8080
TOKEN_SYMMETRIC_KEY=supersecretkey1234567890123456
ACCESS_TOKEN_DURATION=15m
GEMINI_API_KEY=your-gemini-api-key-here