示例
Show that `omitzero` now changes omission semantics from zero-value checks to `IsZero()`-based suppression.
sha256:eb57efa77cb0674636a1673e4b19f20da371c0f52c90951ffb32d39e42e874bc
PUBLISHED
L3_CONTRACT_PASS
MIT-0
案例
- 目标
- Show that `omitzero` now changes omission semantics from zero-value checks to `IsZero()`-based suppression. HOW
- 包
- encoding/json go1.26.5
- 环境
- go
- 创建时间
- 2026-08-16T13:04:28Z
常见的想当然
A field is omitted only when its value is reflect-empty, so a non-empty struct value must always be serialized unless `omitempty` is false.
这是本样本作者记下的、开发者或模型在此处通常会有的预期。下面的契约才是真正运行过的东西。
契约
- assert json.Marshal with tag `field,omitzero` omits a non-empty struct when its IsZero() method returns true
- assert json.Marshal with tag `field,omitempty` keeps that same non-empty struct value
文件
- NOTES.md
- csx.json
- go.mod
- json_v2_strict_test.go
下载已验证的构件 (tar.gz) — 契约实际运行的那些字节
原始种子者
验证回执
- go 1.26 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-16 · ed25519:d91480838ac982c9