Skip to content

Answer what the second round of simulated users got stuck on - #10

Merged
pscheid92 merged 1 commit into
mainfrom
docs-second-simulation
Nov 9, 2026
Merged

pscheid92 merged 1 commit into
mainfrom
docs-second-simulation

Conversation

@pscheid92

Copy link
Copy Markdown
Owner

From the second round: 20 Haiku agents, 8 repeating the hardest cases of the first round and 12 new ones.

  • Embedding trap. The struct pattern from Answer what first-time users got stuck on #9 breaks when others embed the struct: its methods are promoted, and the
    outer struct encodes as the inner one alone. Checked: {"name":"x", RetryPolicy} came out as
    {"initial_backoff":1}. The README now says to use a named field, and links the example in the repository instead
    of pkg.go.dev, which shows it only after a release.
  • WithMarshalers next to With silently drops one of them. This moves from "Good to know" into Usage, with
    joined options as code (compiled and run).
  • Rules people needed for schemas and validation, all checked against the library: exponents rejected, digits
    below a nanosecond truncated, the largest value PT2562047H47M16.854775807S, one - or + in front, "P0.0D"
    rejected, "P0DT2H" written back as "PT2H", values not range-checked, decoding into any gives strings, maps in
    random order unless json.Deterministic(true).
  • Formats Units does not cover: humantime's "1h 30m", PostgreSQL's "01:30:00", and protobuf's "3600s" read
    but written as "1h0m0s".
  • Cost: With costs about 13 allocations (measured with testing.AllocsPerRun), so create options once.

Warn that a struct encoding itself must not be embedded, since the
outer struct then loses its other fields, and link the example in the
repository, which pkg.go.dev shows only after a release.

Move the silent replacement of a second WithMarshalers option into
Usage, with code, and say what creating options costs.

Say what decoding does not check, and the rules a schema needs:
exponents, truncation, the range, the sign, zero counts with a
fraction, the output form, what Units does not read, decoding into any,
and the order of maps.
@pscheid92
pscheid92 merged commit d01c579 into main Nov 9, 2026
19 checks passed
@pscheid92
pscheid92 deleted the docs-second-simulation branch November 9, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant