Skip to content

linter for detect json:"omitempty" usage with value types #3775

@zyfy29

Description

@zyfy29

Empty value types will be unexpectedly omitted with json:"omitempty" tag. The convention here is to use pointer types for optional fields.

Seems that no existing linters could do that. Is it OK to add a custom linter here to check usage like that?

Action string `json:"action,omitempty"`

I only found one place avoiding the role, although the type is a returned type and is rarely marshaled. But it will be helpful to check incoming PRs.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions