Documentation
¶
Overview ¶
Purpose: This file implements the GoCon environment configuration system. It parses a `.env` file and exposes typed getters used throughout the application.
Philosophy: Configuration should be environment-driven and never hardcoded. By reading from a `.env` file at startup, developers can safely switch between local, staging, and production environments without touching source code. We use zero external dependencies — pure stdlib.
Architecture: A single `Manager` struct holds a parsed key→value map loaded once at boot via `Load()`. The global `gostack.Config` facade exposes it to the entire application.
Choice: We chose a simple line-by-line `.env` parser over external libraries (like godotenv) to maintain GoStack's zero-dependency philosophy. The parser handles comments, blank lines, quoted values, and inline comments.
Implementation: - Manager: holds the parsed env map. - Load(path): reads and parses the .env file into the manager. - Get(key): returns raw string value. - GetOrDefault(key, fallback): returns value or fallback if missing. - GetInt(key, fallback): returns int-parsed value or fallback. - GetBool(key, fallback): returns bool-parsed value or fallback.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager holds the parsed environment configuration map.
func (*Manager) GetBool ¶
GetBool returns the boolean value for key. Accepts "true", "1", "yes" (case-insensitive) as truthy. Returns fallback if the key is absent or unrecognized.
func (*Manager) GetInt ¶
GetInt returns the integer value for key, or fallback if the key is absent or cannot be parsed as an integer.
func (*Manager) GetOrDefault ¶
GetOrDefault returns the value for key, falling back to the provided default if the key is absent or empty.