Skip to content

Commit

Permalink
Add missing ",omitempty" option for pointer struct fields. (google#787)
Browse files Browse the repository at this point in the history
This change improves consistency by adding missing ",omitempty"
option where they belong. This makes it so that `nil` values get
omitted when/if marshaled to JSON. Non-nil values are always
included.
  • Loading branch information
sahildua2305 authored and dmitshur committed Nov 22, 2017
1 parent ce4e695 commit 7c5e56e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion github/activity_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
// Event represents a GitHub event.
type Event struct {
Type *string `json:"type,omitempty"`
Public *bool `json:"public"`
Public *bool `json:"public,omitempty"`
RawPayload *json.RawMessage `json:"payload,omitempty"`
Repo *Repository `json:"repo,omitempty"`
Actor *User `json:"actor,omitempty"`
Expand Down
16 changes: 8 additions & 8 deletions github/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Repository struct {
SSHURL *string `json:"ssh_url,omitempty"`
SVNURL *string `json:"svn_url,omitempty"`
Language *string `json:"language,omitempty"`
Fork *bool `json:"fork"`
Fork *bool `json:"fork,omitempty"`
ForksCount *int `json:"forks_count,omitempty"`
NetworkCount *int `json:"network_count,omitempty"`
OpenIssuesCount *int `json:"open_issues_count,omitempty"`
Expand All @@ -61,18 +61,18 @@ type Repository struct {
License *License `json:"license,omitempty"`

// Additional mutable fields when creating and editing a repository
Private *bool `json:"private"`
HasIssues *bool `json:"has_issues"`
HasWiki *bool `json:"has_wiki"`
HasPages *bool `json:"has_pages"`
Private *bool `json:"private,omitempty"`
HasIssues *bool `json:"has_issues,omitempty"`
HasWiki *bool `json:"has_wiki,omitempty"`
HasPages *bool `json:"has_pages,omitempty"`
HasProjects *bool `json:"has_projects,omitempty"`
HasDownloads *bool `json:"has_downloads"`
HasDownloads *bool `json:"has_downloads,omitempty"`
LicenseTemplate *string `json:"license_template,omitempty"`
GitignoreTemplate *string `json:"gitignore_template,omitempty"`
Archived *bool `json:"archived,omitempty"`

// Creating an organization repository. Required for non-owners.
TeamID *int `json:"team_id"`
TeamID *int `json:"team_id,omitempty"`

// API URLs
URL *string `json:"url,omitempty"`
Expand Down Expand Up @@ -405,7 +405,7 @@ type Contributor struct {
EventsURL *string `json:"events_url,omitempty"`
ReceivedEventsURL *string `json:"received_events_url,omitempty"`
Type *string `json:"type,omitempty"`
SiteAdmin *bool `json:"site_admin"`
SiteAdmin *bool `json:"site_admin,omitempty"`
Contributions *int `json:"contributions,omitempty"`
}

Expand Down

0 comments on commit 7c5e56e

Please sign in to comment.