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)。
Click to show internal directories.
Click to hide internal directories.