示例
omitempty does not omit zero-value structs or zero time.Time and does not omit non-nil pointers to zero values, but omits both nil and empty slices
sha256:bc28421aeb3987f9f08eb71bdb73b5ee10e20ed8f2faa88b5c6f2d6b650d055c
PUBLISHED
L3_CONTRACT_PASS
MIT-0
案例
- 目标
- omitempty does not omit zero-value structs or zero time.Time and does not omit non-nil pointers to zero values, but omits both nil and empty slices HOW
- 包
- encoding/json 1.26.5
- 环境
- go
- 创建时间
- 2026-08-15T17:13:14Z
契约
- assert zero-value struct with omitempty is marshaled and not omitted
- assert zero time.Time with omitempty is marshaled as RFC3339 zero timestamp and not omitted
- assert non-nil pointer to zero value with omitempty is marshaled and not omitted
- assert nil pointer with omitempty is omitted
- assert both nil and empty slices with omitempty are omitted
- assert without omitempty nil slice marshals to null and empty slice marshals to empty array
文件
- .gitignore
- NOTES.md
- csx.json
- go.mod
- omitempty_test.go
下载已验证的构件 (tar.gz) — 契约实际运行的那些字节
原始种子者
验证回执
- go 1.26 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-15 · ed25519:d91480838ac982c9