Skip to content

feat: Require Go 1.26 and use new(expr) for pointer literals - #4481

Open
ajayk wants to merge 2 commits into
google:masterfrom
ajayk:go-1.26
Open

feat: Require Go 1.26 and use new(expr) for pointer literals#4481
ajayk wants to merge 2 commits into
google:masterfrom
ajayk:go-1.26

Conversation

@ajayk

@ajayk ajayk commented Aug 23, 2026

Copy link
Copy Markdown

Bump go.mod to 1.26 per the N-1 support policy (Go 1.27 is current) and replace Ptr() with the new(v) builtin across tests.

  Bump go.mod to 1.26 per the N-1 support policy (Go 1.27 is current) and replace Ptr() with the new(v) builtin across tests.
@gmlewis

gmlewis commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

@ajayk - please read step 4 of CONTRIBUTING.md and run the scripts locally to fix all test and linter errors, then push the changes to this PR before we can proceed.

  Bump go.mod to 1.26 per the N-1 support policy (Go 1.27 is current) and replace Ptr() with the new(v) builtin across tests.
@ajayk

ajayk commented Aug 23, 2026

Copy link
Copy Markdown
Author

@ajayk - please read step 4 of CONTRIBUTING.md and run the scripts locally to fix all test and linter errors, then push the changes to this PR before we can proceed.

addressed them sorry about this !

➜  go-github git:(go-1.26) script/fmt.sh
WARN [formatter] gofumpt: `extra-rules` is deprecated, please use `extra.group-params` instead.
WARN [formatter] gofumpt: `extra-rules` is deprecated, please use `extra.group-params` instead.
WARN [formatter] gofumpt: `extra-rules` is deprecated, please use `extra.group-params` instead.
WARN [formatter] gofumpt: `extra-rules` is deprecated, please use `extra.group-params` instead.
WARN [formatter] gofumpt: `extra-rules` is deprecated, please use `extra.group-params` instead.
WARN [formatter] gofumpt: `extra-rules` is deprecated, please use `extra.group-params` instead.
WARN [formatter] gofumpt: `extra-rules` is deprecated, please use `extra.group-params` instead.
WARN [formatter] gofumpt: `extra-rules` is deprecated, please use `extra.group-params` instead.
WARN [formatter] gofumpt: `extra-rules` is deprecated, please use `extra.group-params` instead.
WARN [formatter] gofumpt: `extra-rules` is deprecated, please use `extra.group-params` instead.
WARN [formatter] gofumpt: `extra-rules` is deprecated, please use `extra.group-params` instead.
WARN [formatter] gofumpt: `extra-rules` is deprecated, please use `extra.group-params` instead.
➜  go-github git:(go-1.26) script/test.sh
Testing modules

✔ .                                        [ PASS ]
✔ example                                  [ PASS ]
✔ otel                                     [ PASS ]
✔ scrape                                   [ PASS ]
✔ tools                                    [ PASS ]
✔ tools/check-structfield-settings         [ PASS ]
✔ tools/extraneousnew                      [ PASS ]
✔ tools/fmtpercentv                        [ PASS ]
✔ tools/paramcheck                         [ PASS ]
✔ tools/redundantptr                       [ PASS ]
✔ tools/sliceofpointers                    [ PASS ]
✔ tools/structfield                        [ PASS ]
----------------------------
Testing: issues found in 0 module directories.
--------------------------------------------
➜  go-github git:(go-1.26) script/lint.sh
Linting modules

✔ .                                        [ PASS ]
✔ example                                  [ PASS ]
✔ otel                                     [ PASS ]
✔ scrape                                   [ PASS ]
✔ tools                                    [ PASS ]
✔ tools/check-structfield-settings         [ PASS ]
✔ tools/extraneousnew                      [ PASS ]
✔ tools/fmtpercentv                        [ PASS ]
✔ tools/paramcheck                         [ PASS ]
✔ tools/redundantptr                       [ PASS ]
✔ tools/sliceofpointers                    [ PASS ]
✔ tools/structfield                        [ PASS ]
Validating generated files

✔ Generated files are up to date
----------------------------
Linting: issues found in 0 module directories.
--------------------------------------------

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Aug 23, 2026
@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.51%. Comparing base (30af001) to head (5f86d04).

Files with missing lines Patch % Lines
github/github.go 60.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4481      +/-   ##
==========================================
- Coverage   98.51%   98.51%   -0.01%     
==========================================
  Files         195      195              
  Lines       17691    17685       -6     
==========================================
- Hits        17429    17423       -6     
  Misses        262      262              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis

gmlewis commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

I'm surprised the the Codecov report actually dropped in with this PR, but the bulk of the changes are for deprecated functions that are fixed with go:fix anyway, so I think we can safely ignore Codecov for this PR.

@gmlewis gmlewis left a comment

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.

Thank you, @ajayk!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @alexandear - @Not-Dhananjay-Mishra

@@ -209,10 +209,10 @@ func TestUsers_Keys(t *testing.T) {
// Verify that fetching individual key works
k, _, err := client.Users.GetKey(t.Context(), id)
if err != nil {
t.Fatalf("Users.GetKey(%q) returned error: %v", id, err)
t.Fatalf("Users.GetKey(%d) returned error: %v", id, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use %v?

Suggested change
t.Fatalf("Users.GetKey(%d) returned error: %v", id, err)
t.Fatalf("Users.GetKey(%v) returned error: %v", id, err)

@alexandear alexandear left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please update all occurrences of Ptr with new:

❯ rg "Ptr\(" -c
CONTRIBUTING.md:4
tools/redundantptr/redundantptr.go:2
scrape/apps_test.go:2
tools/redundantptr/testdata/src/has-warnings/github.go:9
github/github-iterators.go:246
tools/redundantptr/testdata/src/no-warnings/github.go:9
README.md:2
github/github-stringify_test.go:976
github/gen-iterators.go:1
github/gen-stringify-test.go:11
github/github.go:2
github/github_test.go:4
github/doc.go:2

Comment thread go.mod

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please change to 1.26 in all go.mod files:

❯ rg "go 1.25"
scrape/go.mod
3:go 1.25.0

tools/extraneousnew/go.mod
3:go 1.25.0

tools/redundantptr/go.mod
3:go 1.25.0

tools/structfield/go.mod
3:go 1.25.0

tools/fmtpercentv/go.mod
3:go 1.25.0

tools/check-structfield-settings/go.mod
3:go 1.25.0

tools/paramcheck/go.mod
3:go 1.25.0

tools/sliceofpointers/go.mod
3:go 1.25.0

Comment thread go.mod

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please update this line:

don't explicitly test older versions and as of Go 1.23 the go directive in

Comment thread github/github.go

// Ptr is a helper routine that allocates a new T value
// to store v and returns a pointer to it.
//

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please mark this function as deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants