From 705b6fcf573b2e910369aa553518036d9c1572a9 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Fri, 7 May 2021 09:38:36 -0400 Subject: [PATCH 1/2] Change all *map to map in JSON structs --- github/github-accessors.go | 12 ++++++------ github/github-accessors_test.go | 12 ++++++------ github/repos.go | 2 +- github/teams.go | 2 +- github/users.go | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index e6f349436bb..9014a44c229 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -12420,12 +12420,12 @@ func (r *Repository) GetParent() *Repository { return r.Parent } -// GetPermissions returns the Permissions field if it's non-nil, zero value otherwise. +// GetPermissions returns the Permissions map if it's non-nil, an empty map otherwise. func (r *Repository) GetPermissions() map[string]bool { if r == nil || r.Permissions == nil { return map[string]bool{} } - return *r.Permissions + return r.Permissions } // GetPrivate returns the Private field if it's non-nil, zero value otherwise. @@ -14308,12 +14308,12 @@ func (t *Team) GetPermission() string { return *t.Permission } -// GetPermissions returns the Permissions field if it's non-nil, zero value otherwise. +// GetPermissions returns the Permissions map if it's non-nil, an empty map otherwise. func (t *Team) GetPermissions() map[string]bool { if t == nil || t.Permissions == nil { return map[string]bool{} } - return *t.Permissions + return t.Permissions } // GetPrivacy returns the Privacy field if it's non-nil, zero value otherwise. @@ -15396,12 +15396,12 @@ func (u *User) GetOwnedPrivateRepos() int { return *u.OwnedPrivateRepos } -// GetPermissions returns the Permissions field if it's non-nil, zero value otherwise. +// GetPermissions returns the Permissions map if it's non-nil, an empty map otherwise. func (u *User) GetPermissions() map[string]bool { if u == nil || u.Permissions == nil { return map[string]bool{} } - return *u.Permissions + return u.Permissions } // GetPlan returns the Plan field. diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 2c449f8b2d0..f14df52a4a0 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -14534,8 +14534,8 @@ func TestRepository_GetParent(tt *testing.T) { } func TestRepository_GetPermissions(tt *testing.T) { - var zeroValue map[string]bool - r := &Repository{Permissions: &zeroValue} + zeroValue := map[string]bool{} + r := &Repository{Permissions: zeroValue} r.GetPermissions() r = &Repository{} r.GetPermissions() @@ -16762,8 +16762,8 @@ func TestTeam_GetPermission(tt *testing.T) { } func TestTeam_GetPermissions(tt *testing.T) { - var zeroValue map[string]bool - t := &Team{Permissions: &zeroValue} + zeroValue := map[string]bool{} + t := &Team{Permissions: zeroValue} t.GetPermissions() t = &Team{} t.GetPermissions() @@ -18056,8 +18056,8 @@ func TestUser_GetOwnedPrivateRepos(tt *testing.T) { } func TestUser_GetPermissions(tt *testing.T) { - var zeroValue map[string]bool - u := &User{Permissions: &zeroValue} + zeroValue := map[string]bool{} + u := &User{Permissions: zeroValue} u.GetPermissions() u = &User{} u.GetPermissions() diff --git a/github/repos.go b/github/repos.go index 989f2756adf..a7c433bfd02 100644 --- a/github/repos.go +++ b/github/repos.go @@ -53,7 +53,7 @@ type Repository struct { Source *Repository `json:"source,omitempty"` TemplateRepository *Repository `json:"template_repository,omitempty"` Organization *Organization `json:"organization,omitempty"` - Permissions *map[string]bool `json:"permissions,omitempty"` + Permissions map[string]bool `json:"permissions,omitempty"` AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"` AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"` AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"` diff --git a/github/teams.go b/github/teams.go index 2e1cd3dafe9..67106d1d595 100644 --- a/github/teams.go +++ b/github/teams.go @@ -34,7 +34,7 @@ type Team struct { // Permissions identifies the permissions that a team has on a given // repository. This is only populated when calling Repositories.ListTeams. - Permissions *map[string]bool `json:"permissions,omitempty"` + Permissions map[string]bool `json:"permissions,omitempty"` // Privacy identifies the level of privacy this team should have. // Possible values are: diff --git a/github/users.go b/github/users.go index 38daece31d5..f45b1f6711b 100644 --- a/github/users.go +++ b/github/users.go @@ -68,7 +68,7 @@ type User struct { // Permissions identifies the permissions that a user has on a given // repository. This is only populated when calling Repositories.ListCollaborators. - Permissions *map[string]bool `json:"permissions,omitempty"` + Permissions map[string]bool `json:"permissions,omitempty"` } func (u User) String() string { From 4ba396a481aad50a34bb45867cbb86c5450e1671 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Fri, 7 May 2021 09:52:03 -0400 Subject: [PATCH 2/2] Run gofmt --- github/repos.go | 80 ++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/github/repos.go b/github/repos.go index a7c433bfd02..a7ec9d11f19 100644 --- a/github/repos.go +++ b/github/repos.go @@ -20,47 +20,47 @@ type RepositoriesService service // Repository represents a GitHub repository. type Repository struct { - ID *int64 `json:"id,omitempty"` - NodeID *string `json:"node_id,omitempty"` - Owner *User `json:"owner,omitempty"` - Name *string `json:"name,omitempty"` - FullName *string `json:"full_name,omitempty"` - Description *string `json:"description,omitempty"` - Homepage *string `json:"homepage,omitempty"` - CodeOfConduct *CodeOfConduct `json:"code_of_conduct,omitempty"` - DefaultBranch *string `json:"default_branch,omitempty"` - MasterBranch *string `json:"master_branch,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - PushedAt *Timestamp `json:"pushed_at,omitempty"` - UpdatedAt *Timestamp `json:"updated_at,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - CloneURL *string `json:"clone_url,omitempty"` - GitURL *string `json:"git_url,omitempty"` - MirrorURL *string `json:"mirror_url,omitempty"` - SSHURL *string `json:"ssh_url,omitempty"` - SVNURL *string `json:"svn_url,omitempty"` - Language *string `json:"language,omitempty"` - Fork *bool `json:"fork,omitempty"` - ForksCount *int `json:"forks_count,omitempty"` - NetworkCount *int `json:"network_count,omitempty"` - OpenIssuesCount *int `json:"open_issues_count,omitempty"` - StargazersCount *int `json:"stargazers_count,omitempty"` - SubscribersCount *int `json:"subscribers_count,omitempty"` - WatchersCount *int `json:"watchers_count,omitempty"` - Size *int `json:"size,omitempty"` - AutoInit *bool `json:"auto_init,omitempty"` - Parent *Repository `json:"parent,omitempty"` - Source *Repository `json:"source,omitempty"` - TemplateRepository *Repository `json:"template_repository,omitempty"` - Organization *Organization `json:"organization,omitempty"` + ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` + Owner *User `json:"owner,omitempty"` + Name *string `json:"name,omitempty"` + FullName *string `json:"full_name,omitempty"` + Description *string `json:"description,omitempty"` + Homepage *string `json:"homepage,omitempty"` + CodeOfConduct *CodeOfConduct `json:"code_of_conduct,omitempty"` + DefaultBranch *string `json:"default_branch,omitempty"` + MasterBranch *string `json:"master_branch,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + PushedAt *Timestamp `json:"pushed_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + CloneURL *string `json:"clone_url,omitempty"` + GitURL *string `json:"git_url,omitempty"` + MirrorURL *string `json:"mirror_url,omitempty"` + SSHURL *string `json:"ssh_url,omitempty"` + SVNURL *string `json:"svn_url,omitempty"` + Language *string `json:"language,omitempty"` + Fork *bool `json:"fork,omitempty"` + ForksCount *int `json:"forks_count,omitempty"` + NetworkCount *int `json:"network_count,omitempty"` + OpenIssuesCount *int `json:"open_issues_count,omitempty"` + StargazersCount *int `json:"stargazers_count,omitempty"` + SubscribersCount *int `json:"subscribers_count,omitempty"` + WatchersCount *int `json:"watchers_count,omitempty"` + Size *int `json:"size,omitempty"` + AutoInit *bool `json:"auto_init,omitempty"` + Parent *Repository `json:"parent,omitempty"` + Source *Repository `json:"source,omitempty"` + TemplateRepository *Repository `json:"template_repository,omitempty"` + Organization *Organization `json:"organization,omitempty"` Permissions map[string]bool `json:"permissions,omitempty"` - AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"` - AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"` - AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"` - DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"` - Topics []string `json:"topics,omitempty"` - Archived *bool `json:"archived,omitempty"` - Disabled *bool `json:"disabled,omitempty"` + AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"` + AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"` + AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"` + DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"` + Topics []string `json:"topics,omitempty"` + Archived *bool `json:"archived,omitempty"` + Disabled *bool `json:"disabled,omitempty"` // Only provided when using RepositoriesService.Get while in preview License *License `json:"license,omitempty"`