Пример
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