Help us shape the future of Go! Take the 2026 Go Developer Survey

check_omitempty

command
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

check_omitempty 检查所有 Update*Input 结构体的字段是否都有 omitempty json tag。 用法:go run ./scripts/check_omitempty ./app/...

背景:PatchAndSave 用 json.Marshal/Unmarshal 合并字段,依赖 omitempty 跳过零值。 如果 Update*Input 的字段缺少 omitempty,json.Marshal 会序列化零值,导致 PatchAndSave 覆盖 entity 的原有字段为零值。

例外:在结构体上方加 //nolint:omitempty 注释可跳过检查(用于不走 PatchAndSave 的 Input)。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL