pattern-custom-format

command
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package pattern-custom-format demonstrates ports.Pattern's CustomFormat escape hatch: FilePattern, CachePattern, and SocketPattern are normally locked to FileFormatKind{JSON, YAML, TOML} — CustomFormat lets a port declare ANY format.Format[T] instead (Gob, raw binary/PNG, or any custom marshal/unmarshal), closing the gap without waiting for go-codex to add a new enum value for every future wire format.

Two scenes:

  • FilePattern + format.Binary(pngCodec): a typed IOPort whose "file" is a raw PNG blob — content stays binary, never JSON-wrapped.
  • CachePattern + format.Gob(structCodec): a typed cache entry encoded with encoding/gob instead of JSON — smaller, Go-native, no map intermediate.

Running

go run ./examples/pattern-custom-format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL