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
Click to show internal directories.
Click to hide internal directories.