Examples
Complete working examples for env.zig.
Running Examples
bash
# Run all examples (13 total)
zig build example
# Run a specific example
zig-out/bin/basic_example
zig-out/bin/interpolation_example
zig-out/bin/clone_merge_example
zig-out/bin/cache_example
zig-out/bin/iterator_example
zig-out/bin/validation_example
zig-out/bin/serialization_example
zig-out/bin/runtime_example
zig-out/bin/file_io_example
zig-out/bin/error_handling_example
zig-out/bin/type_safe_example
zig-out/bin/unicode_example
zig-out/bin/child_env_exampleAvailable Examples
| Example | Description |
|---|---|
| Basic | Set/get, explicit .env + .env.local creation, loadMany override |
| Interpolation | Variable interpolation with ${VAR} syntax |
| Clone & Merge | Independent copies and default value merging |
| Cache | Standalone cache for parsed values |
| Iterator | Borrowed iterator with peek, skip, reset, and collect |
| Validation | Schema validation with built-in validators |
| Serialization | Serialize to .env format with sorting and quoting |
| Runtime | Cross-platform runtime env via env.runtime with scope & snapshot |
| Child Env | toEnvironMap/applyToEnvironMap for child processes |
| Unicode | UTF-8 values, emoji, runtime round-trip |
| File I/O | Load/save, loadMany, reload, prefix filtering, export |
| Error Handling | Strict mode, diagnostics, FileNotFound, validation levels |
| Type-Safe | getBool/getInt/getFloat/getEnum/getList/getValue with runtime fallback |
