env
A high-security Go environment variable management library supporting .env, JSON, and YAML formats, with thread safety, audit logging, and secure storage.
Core Features
- Multi-format support -
.env, JSON, YAML auto-detection - Type safety - automatic type conversion and validation
- Thread safety - concurrent access with sharded locks
- Secure storage - memory locking and auto-zeroing for sensitive values
- Audit logging - complete operation tracking
- Variable expansion -
${VAR}syntax support - Struct mapping - tag-driven configuration binding
Navigate by Use Case
Not sure where to start? Choose by your need:
| I want to... | Where to look |
|---|---|
| Get started in 5 minutes | Quick Start |
| Store passwords and keys securely | Security Overview → SecureValue |
| Prevent sensitive data from being swapped to disk | Memory Locking |
| Safely handle sensitive data in logs | Data Masking |
| Map environment variables to a struct | Struct Mapping |
| Load JSON/YAML config files | Multi-format Config |
| Configure variable references and reuse | Variable Expansion |
| Serialize/export configuration | Serialization |
| Record security audit logs | Audit Logging |
| Handle and match errors | Error Handling |
| Write unit tests | Testing |
| Extend with custom file formats | Custom Parser |
| Security checks before going live | Production Checklist |
| See common code snippets | Cheat Sheet |
| Find answers to common questions | FAQ |
Key Features Overview
| Feature | Description |
|---|---|
| Type Conversion | GetString, GetInt, GetBool, GetDuration, GetSlice |
| Struct Mapping | Tag-driven configuration binding |
| Secure Storage | Memory protection for sensitive values |
| Multi-format Loading | .env, JSON, YAML |
Quick Navigation
Getting Started
- Quick Start - 5-minute tutorial
- Cheat Sheet - Common code snippets
API Reference
- Package Functions - Complete API documentation
- Loader - Loader methods
- SecureValue - Secure value handling
Security
- Security Overview - Security architecture and best practices