-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Description
With the release of Go 1.24 we now have the omitzero JSON struct tag. Using this tag we can differentiate between an unset array and an empty array, this would allow us to simplify the API surface for endpoints where this distinction is required.
For example the following single change would allow us to remove the 3 functions required to clear the BypassActors which in turn would make the calling code significantly simpler.
// RepositoryRuleset represents a GitHub ruleset object.
type RepositoryRuleset struct {
ID *int64 `json:"id,omitempty"`
Name string `json:"name"`
Target *RulesetTarget `json:"target,omitempty"`
SourceType *RulesetSourceType `json:"source_type,omitempty"`
Source string `json:"source"`
Enforcement RulesetEnforcement `json:"enforcement"`
BypassActors []*BypassActor `json:"bypass_actors,omitzero"` // Was omitempty
CurrentUserCanBypass *BypassMode `json:"current_user_can_bypass,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Links *RepositoryRulesetLinks `json:"_links,omitempty"`
Conditions *RepositoryRulesetConditions `json:"conditions,omitempty"`
Rules *RepositoryRulesetRules `json:"rules,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
}We could also use omitzero instead of pointers in some cases, but this is explicitly not covered by this issue.
gmlewis and Not-Dhananjay-Mishra
Metadata
Metadata
Assignees
Labels
No labels