Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .custom-gcl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ plugins:
path: ./tools/extraneousnew
- module: "github.com/google/go-github/v84/tools/fmtpercentv"
path: ./tools/fmtpercentv
- module: "github.com/google/go-github/v84/tools/redundantptr"
path: ./tools/redundantptr
- module: "github.com/google/go-github/v84/tools/sliceofpointers"
path: ./tools/sliceofpointers
- module: "github.com/google/go-github/v84/tools/structfield"
Expand Down
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ linters:
- nolintlint
- paralleltest
- perfsprint
- redundantptr
- revive
- sliceofpointers
- staticcheck
Expand Down Expand Up @@ -193,6 +194,10 @@ linters:
type: module
description: Reports usage of %d or %s in format strings.
original-url: github.com/google/go-github/v84/tools/fmtpercentv
redundantptr:
type: module
description: Reports github.Ptr(x) calls that can be replaced with &x.
original-url: github.com/google/go-github/v84/tools/redundantptr
sliceofpointers:
type: module
description: Reports usage of []*string and slices of structs without pointers.
Expand Down
2 changes: 1 addition & 1 deletion example/commitpr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func getTree(ref *github.Reference) (tree *github.Tree, err error) {
if err != nil {
return nil, err
}
entries = append(entries, &github.TreeEntry{Path: github.Ptr(file), Type: github.Ptr("blob"), Content: github.Ptr(string(content)), Mode: github.Ptr("100644")})
entries = append(entries, &github.TreeEntry{Path: &file, Type: github.Ptr("blob"), Content: github.Ptr(string(content)), Mode: github.Ptr("100644")})
}

tree, _, err = client.Git.CreateTree(ctx, *sourceOwner, *sourceRepo, *ref.Object.SHA, entries)
Expand Down
12 changes: 6 additions & 6 deletions github/actions_hosted_runners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestActionsService_ListHostedRunners(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
},
{
ID: Ptr(int64(7)),
Expand All @@ -132,7 +132,7 @@ func TestActionsService_ListHostedRunners(t *testing.T) {
MaximumRunners: Ptr(int64(20)),
PublicIPEnabled: Ptr(false),
PublicIPs: []*HostedRunnerPublicIP{},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
},
},
}
Expand Down Expand Up @@ -236,7 +236,7 @@ func TestActionsService_CreateHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
}

if !cmp.Equal(hostedRunner, want) {
Expand Down Expand Up @@ -652,7 +652,7 @@ func TestActionsService_GetHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
}

if !cmp.Equal(hostedRunner, want) {
Expand Down Expand Up @@ -748,7 +748,7 @@ func TestActionsService_UpdateHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
}

if !cmp.Equal(hostedRunner, want) {
Expand Down Expand Up @@ -837,7 +837,7 @@ func TestActionsService_DeleteHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
}

if !cmp.Equal(hostedRunner, want) {
Expand Down
4 changes: 2 additions & 2 deletions github/actions_runner_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
},
{
ID: Ptr(int64(7)),
Expand All @@ -534,7 +534,7 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) {
MaximumRunners: Ptr(int64(20)),
PublicIPEnabled: Ptr(false),
PublicIPs: []*HostedRunnerPublicIP{},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion github/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func (s *AppsService) CreateInstallationTokenListRepos(ctx context.Context, id i
//meta:operation POST /repos/{owner}/{repo}/content_references/{content_reference_id}/attachments
func (s *AppsService) CreateAttachment(ctx context.Context, contentReferenceID int64, title, body string) (*Attachment, *Response, error) {
u := fmt.Sprintf("content_references/%v/attachments", contentReferenceID)
payload := &Attachment{Title: Ptr(title), Body: Ptr(body)}
payload := &Attachment{Title: &title, Body: &body}
req, err := s.client.NewRequest("POST", u, payload)
if err != nil {
return nil, nil, err
Expand Down
12 changes: 6 additions & 6 deletions github/enterprise_actions_hosted_runners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
},
{
ID: Ptr(int64(7)),
Expand All @@ -132,7 +132,7 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) {
MaximumRunners: Ptr(int64(20)),
PublicIPEnabled: Ptr(false),
PublicIPs: []*HostedRunnerPublicIP{},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
},
},
}
Expand Down Expand Up @@ -235,7 +235,7 @@ func TestEnterpriseService_CreateHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
}

if !cmp.Equal(hostedRunner, want) {
Expand Down Expand Up @@ -650,7 +650,7 @@ func TestEnterpriseService_GetHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
}

if !cmp.Equal(hostedRunner, want) {
Expand Down Expand Up @@ -747,7 +747,7 @@ func TestEnterpriseService_UpdateHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
}

if !cmp.Equal(hostedRunner, want) {
Expand Down Expand Up @@ -836,7 +836,7 @@ func TestEnterpriseService_DeleteHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: &lastActiveOn,
}

if !cmp.Equal(hostedRunner, want) {
Expand Down
6 changes: 3 additions & 3 deletions github/git_commits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func TestGitService_CreateSignedCommit(t *testing.T) {
Tree: &Tree{SHA: Ptr("t")},
Parents: []*Commit{{SHA: Ptr("p")}},
Verification: &SignatureVerification{
Signature: Ptr(signature),
Signature: &signature,
},
}

Expand All @@ -249,7 +249,7 @@ func TestGitService_CreateSignedCommit(t *testing.T) {
Message: input.Message,
Tree: Ptr("t"),
Parents: []string{"p"},
Signature: Ptr(signature),
Signature: &signature,
}
if !cmp.Equal(v, want) {
t.Errorf("Request body = %+v, want %+v", v, want)
Expand Down Expand Up @@ -336,7 +336,7 @@ Commit Message.`
fmt.Fprintf(w, `{"sha":"%v"}`, sha)
})
ctx := t.Context()
wantCommit := &Commit{SHA: Ptr(sha)}
wantCommit := &Commit{SHA: &sha}
opts := CreateCommitOptions{Signer: mockSigner(t, signature, nil, wantMessage)}
commit, _, err := client.Git.CreateCommit(ctx, "o", "r", input, &opts)
assertNilError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion github/interactions_orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (s *InteractionsService) GetRestrictionsForOrg(ctx context.Context, organiz
func (s *InteractionsService) UpdateRestrictionsForOrg(ctx context.Context, organization, limit string) (*InteractionRestriction, *Response, error) {
u := fmt.Sprintf("orgs/%v/interaction-limits", organization)

interaction := &InteractionRestriction{Limit: Ptr(limit)}
interaction := &InteractionRestriction{Limit: &limit}

req, err := s.client.NewRequest("PUT", u, interaction)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion github/interactions_repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (s *InteractionsService) GetRestrictionsForRepo(ctx context.Context, owner,
func (s *InteractionsService) UpdateRestrictionsForRepo(ctx context.Context, owner, repo, limit string) (*InteractionRestriction, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo)

interaction := &InteractionRestriction{Limit: Ptr(limit)}
interaction := &InteractionRestriction{Limit: &limit}

req, err := s.client.NewRequest("PUT", u, interaction)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions github/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ type markdownRenderRequest struct {
//
//meta:operation POST /markdown
func (s *MarkdownService) Render(ctx context.Context, text string, opts *MarkdownOptions) (string, *Response, error) {
request := &markdownRenderRequest{Text: Ptr(text)}
request := &markdownRenderRequest{Text: &text}
if opts != nil {
if opts.Mode != "" {
request.Mode = Ptr(opts.Mode)
request.Mode = &opts.Mode
}
if opts.Context != "" {
request.Context = Ptr(opts.Context)
request.Context = &opts.Context
}
}

Expand Down
6 changes: 3 additions & 3 deletions github/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ func (s *MigrationService) StartMigration(ctx context.Context, org string, repos

body := &startMigration{Repositories: repos}
if opts != nil {
body.LockRepositories = Ptr(opts.LockRepositories)
body.ExcludeAttachments = Ptr(opts.ExcludeAttachments)
body.ExcludeReleases = Ptr(opts.ExcludeReleases)
body.LockRepositories = &opts.LockRepositories
body.ExcludeAttachments = &opts.ExcludeAttachments
body.ExcludeReleases = &opts.ExcludeReleases
body.Exclude = append(body.Exclude, opts.Exclude...)
}

Expand Down
4 changes: 2 additions & 2 deletions github/migrations_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func (s *MigrationService) StartUserMigration(ctx context.Context, repos []strin

body := &startUserMigration{Repositories: repos}
if opts != nil {
body.LockRepositories = Ptr(opts.LockRepositories)
body.ExcludeAttachments = Ptr(opts.ExcludeAttachments)
body.LockRepositories = &opts.LockRepositories
body.ExcludeAttachments = &opts.ExcludeAttachments
}

req, err := s.client.NewRequest("POST", u, body)
Expand Down
14 changes: 7 additions & 7 deletions github/reactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (s *ReactionsService) ListCommentReactions(ctx context.Context, owner, repo
func (s *ReactionsService) CreateCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/comments/%v/reactions", owner, repo, id)

body := &Reaction{Content: Ptr(content)}
body := &Reaction{Content: &content}
req, err := s.client.NewRequest("POST", u, body)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -174,7 +174,7 @@ func (s *ReactionsService) ListIssueReactions(ctx context.Context, owner, repo s
func (s *ReactionsService) CreateIssueReaction(ctx context.Context, owner, repo string, number int, content string) (*Reaction, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/issues/%v/reactions", owner, repo, number)

body := &Reaction{Content: Ptr(content)}
body := &Reaction{Content: &content}
req, err := s.client.NewRequest("POST", u, body)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -252,7 +252,7 @@ func (s *ReactionsService) ListIssueCommentReactions(ctx context.Context, owner,
func (s *ReactionsService) CreateIssueCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/issues/comments/%v/reactions", owner, repo, id)

body := &Reaction{Content: Ptr(content)}
body := &Reaction{Content: &content}
req, err := s.client.NewRequest("POST", u, body)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -330,7 +330,7 @@ func (s *ReactionsService) ListPullRequestCommentReactions(ctx context.Context,
func (s *ReactionsService) CreatePullRequestCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%v/reactions", owner, repo, id)

body := &Reaction{Content: Ptr(content)}
body := &Reaction{Content: &content}
req, err := s.client.NewRequest("POST", u, body)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -406,7 +406,7 @@ func (s *ReactionsService) ListTeamDiscussionReactions(ctx context.Context, team
func (s *ReactionsService) CreateTeamDiscussionReaction(ctx context.Context, teamID int64, discussionNumber int, content string) (*Reaction, *Response, error) {
u := fmt.Sprintf("teams/%v/discussions/%v/reactions", teamID, discussionNumber)

body := &Reaction{Content: Ptr(content)}
body := &Reaction{Content: &content}
req, err := s.client.NewRequest("POST", u, body)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -481,7 +481,7 @@ func (s *ReactionsService) ListTeamDiscussionCommentReactions(ctx context.Contex
func (s *ReactionsService) CreateTeamDiscussionCommentReaction(ctx context.Context, teamID int64, discussionNumber, commentNumber int, content string) (*Reaction, *Response, error) {
u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v/reactions", teamID, discussionNumber, commentNumber)

body := &Reaction{Content: Ptr(content)}
body := &Reaction{Content: &content}
req, err := s.client.NewRequest("POST", u, body)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -542,7 +542,7 @@ func (s *ReactionsService) deleteReaction(ctx context.Context, url string) (*Res
func (s *ReactionsService) CreateReleaseReaction(ctx context.Context, owner, repo string, releaseID int64, content string) (*Reaction, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/releases/%v/reactions", owner, repo, releaseID)

body := &Reaction{Content: Ptr(content)}
body := &Reaction{Content: &content}
req, err := s.client.NewRequest("POST", u, body)
if err != nil {
return nil, nil, err
Expand Down
2 changes: 1 addition & 1 deletion github/repos_hooks_deliveries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func TestHookDelivery_ParsePayload(t *testing.T) {
p := json.RawMessage(bs)

d := &HookDelivery{
Event: Ptr(evt),
Event: &evt,
Request: &HookRequest{
RawPayload: &p,
},
Expand Down
4 changes: 2 additions & 2 deletions github/repos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ func TestRepositoriesService_GetBranchProtection(t *testing.T) {
RequireLastPushApproval: false,
},
EnforceAdmins: &AdminEnforcement{
URL: Ptr(test.enforceAdminsURLPath),
URL: &test.enforceAdminsURLPath,
Enabled: true,
},
Restrictions: &BranchRestrictions{
Expand Down Expand Up @@ -1411,7 +1411,7 @@ func TestRepositoriesService_GetBranchProtection_noDismissalRestrictions(t *test
RequiredApprovingReviewCount: 1,
},
EnforceAdmins: &AdminEnforcement{
URL: Ptr(test.enforceAdminsURLPath),
URL: &test.enforceAdminsURLPath,
Enabled: true,
},
Restrictions: &BranchRestrictions{
Expand Down
3 changes: 1 addition & 2 deletions github/strings_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ type BenchmarkStruct struct {
}

func BenchmarkStringify(b *testing.B) {
val := 42
s := &BenchmarkStruct{
Name: "benchmark",
Age: 30,
Active: true,
Score: 1.1,
Rank: 99.999999,
Tags: []string{"go", "github", "api"},
Pointer: Ptr(val),
Pointer: Ptr(42),
}
b.ResetTimer()
for b.Loop() {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func createRandomTestRepository(t *testing.T, owner string, autoinit bool) *gith
t.Context(),
owner,
&github.Repository{
Name: github.Ptr(repoName),
AutoInit: github.Ptr(autoinit),
Name: &repoName,
AutoInit: &autoinit,
},
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func TestUsers_Keys(t *testing.T) {
// Add new key
_, _, err = client.Users.CreateKey(t.Context(), &github.Key{
Title: github.Ptr("go-github test key"),
Key: github.Ptr(key),
Key: &key,
})
if err != nil {
t.Fatalf("Users.CreateKey() returned error: %v", err)
Expand Down
13 changes: 13 additions & 0 deletions tools/redundantptr/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module tools/redundantptr

go 1.25.0

require (
github.com/golangci/plugin-module-register v0.1.2
golang.org/x/tools v0.43.0
)

require (
golang.org/x/mod v0.34.0 // indirect
golang.org/x/sync v0.20.0 // indirect
)
Comment on lines +5 to +13
Copy link
Copy Markdown
Collaborator

@gmlewis gmlewis Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work?
I had to do something similar in tools/check-structfield-settings/go.mod.

require (
	github.com/golangci/plugin-module-register v0.1.2
	github.com/google/go-github/v84/github v0.0.0
	golang.org/x/tools v0.43.0
)

require (
	golang.org/x/mod v0.34.0 // indirect
	golang.org/x/sync v0.20.0 // indirect
)

// Use version at HEAD, not the latest published.
replace github.com/google/go-github/v84/github v0.0.0 => ../../../github

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHUPS! See edit above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it won't work. analysistest uses GOPATH-style package resolution under testdata/src/ and doesn't consult go.mod or replace directives at all.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bummer, OK.

Loading
Loading