The highest tagged major version is
v6 .
Discover Packages
github.com/brunoga/deep/v5
examples
directory
Version:
v5.8.0
Opens a new window with list of versions in this module.
Published: Sep 1, 2026
License: Apache-2.0
Opens a new window with license information.
README
README
¶
Examples
Every directory here is a self-contained, runnable program built around one
concept:
go run ./examples/config_manager
They are meant to be read as much as run — each prints its intermediate state so
you can follow what the library did and why.
Start here
If you are new to the library, these four cover the shape of everything else:
config_manager — the core loop: diff two values,
apply the patch, roll it back with Reverse.
nested_structs — how paths address fields, including
nested and embedded structs, and how a diff pinpoints what changed.
policy_engine — conditions travelling inside the
patch, so the rule is enforced wherever it is applied.
json_interop — what a patch looks like on the wire, in
both the native format and RFC 6902.
Core operations and patches
Example
Shows
config_manager
Diff → Apply → Reverse for rollback
state_management
An undo stack built by keeping each edit's reverse patch
nested_structs
Paths into nested structs; embedded fields addressed by type name; a selector targeting one nested field
slice_paths
At for positional elements; why a length-changing diff becomes one whole-slice replace while a same-length one stays per-index
keyed_inventory
deep:"key" — elements addressed by identity, so reordering produces no operations and a changed element diffs down to the changed field
struct_map_keys
Non-string map keys rendered into paths
move_copy_ops
Move (empties the source) versus Copy (leaves it intact)
multi_error
Apply collecting every failure instead of stopping at the first; unwrapping ApplyError
Example
Shows
atomic_config
deep:"readonly" rejecting writes; deep:"atomic" replacing a struct as one unit
ignored_fields
json:"-" and deep:"-" keeping secrets out of patches — and the sharp edge that invisible means invisible to Clone too
policy_engine
A patch-level Guard built from And/Or/Matches: all-or-nothing
conditional_ops
Per-operation If/Unless: one patch, each operation deciding for itself
concurrent_updates
Strict mode as optimistic locking — a stale patch is rejected
three_way_merge
Merge with a custom ConflictResolver
reflection_fallback
What the reflection engine handles that generated code cannot: unexported fields and cyclic structures
Transport and interop
Example
Shows
json_interop
Native JSON, RFC 6902 export, and ingesting an externally-produced JSON Patch with ParseJSONPatch
http_patch_api
A patch-driven HTTP PATCH endpoint, client and server
websocket_sync
Broadcasting per-tick state deltas to a client
audit_logging
A diff read as an audit trail, plus OpLog tracing through an injected slog.Logger
CRDTs
Example
Shows
crdt_sync
Two nodes exchanging deltas and converging
crdt_undo_redo
Distributed undo/redo via Reverse, and why redelivering a delta is harmless
crdt_containers
Counter, Set (add-wins) and Map (last-write-wins per key)
crdt_list
List[T]: concurrent insertions and deletions in a sequence all survive, where an ordinary slice would keep one writer's version
crdt_observers
OnChange: the operations actually applied, for redrawing only what moved
crdt_compaction
Compact: reclaiming the bookkeeping and tombstones a long-lived replica accumulates, and the watermark that makes it safe
lww_fields
Per-field LWW[T] registers resolving a genuine write conflict
text_sync
Collaborative text: concurrent edits across a partition, merged with MergeTextRuns
Generated code
Examples whose model types have a //go:generate directive ship the generated
*_deep.go file alongside, exercising the reflection-free fast path; the rest
run on the reflection engine. Both are the same API — go generate ./...
regenerates every one of them.
Expand ▾
Collapse ▴
Directories
¶
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Code generated by deep-gen.
Click to show internal directories.
Click to hide internal directories.