Files
obitools4/autodoc/docmd/pkg/obidefault/compressed.md
T
Eric Coissac 8c7017a99d ⬆️ version bump to v4.5
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5"
- Update version.txt from 4.29 → .30
(automated by Makefile)
2026-04-13 13:34:53 +02:00

1.3 KiB

Output Compression Control Module

This Go package (obidefault) provides a simple, global configuration mechanism for toggling output compression behavior across an application.

Core Features

  • Global Compression Flag: A package-level boolean variable __compress__ (default: false) controls whether output should be compressed.
  • Read Access:
    • CompressOutput() returns the current compression setting as a boolean.
  • Write Access:
    • SetCompressOutput(b bool) updates the compression flag to a new value.
  • Pointer Access:
    • CompressOutputPtr() returns a pointer to the internal flag, enabling indirect modification (e.g., for UI bindings or reflection-based updates).

Design Intent

  • Minimal, side-effect-free API.
  • Thread-safety not guaranteed — intended for use in single-threaded initialization or controlled environments.
  • Encapsulation via unexported variable __compress__, enforced through accessor functions.

Typical Usage

// Enable compression globally:
obidefault.SetCompressOutput(true)

if obidefault.CompressOutput() {
    // Apply compression logic (e.g., gzip, brotli)
}

Notes

  • The double underscore prefix (__compress__) signals internal/private status (convention, not enforced).
  • Designed for runtime configurability without recompilation.