refactor: Remove redundant github.Ptr calls#4145
Conversation
github.Ptr calls
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4145 +/- ##
==========================================
- Coverage 93.74% 93.70% -0.04%
==========================================
Files 211 210 -1
Lines 19685 18996 -689
==========================================
- Hits 18453 17801 -652
+ Misses 1034 1009 -25
+ Partials 198 186 -12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @alexandear!
Just one file deletion, then LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
cc: @stevehipwell - @zyfy29 - @Not-Dhananjay-Mishra - @munlicode
| @@ -0,0 +1,10 @@ | |||
| // Copyright 2026 The go-github AUTHORS. All rights reserved. | |||
There was a problem hiding this comment.
I think this file can be completely deleted.
There was a problem hiding this comment.
We can't remove this file because it's used in tests:
❯ go test ./...
--- FAIL: TestRun (0.16s)
analysistest.go:417: src/has-warnings/main.go:9:2: cannot find package "github.com/google/go-github/v84/github" in any of:
/opt/homebrew/Cellar/go/1.26.2/libexec/src/github.com/google/go-github/v84/github (from $GOROOT)
/Users/alexandear/src/github.com/google/go-github/tools/redundantptr/testdata/src/github.com/google/go-github/v84/github (from $GOPATH)
analysistest.go:417: /Users/alexandear/src/github.com/google/go-github/tools/redundantptr/testdata/src/has-warnings/main.go:9:2: could not import github.com/google/go-github/v84/github (invalid package name: "")
analysistest.go:417: /Users/alexandear/src/github.com/google/go-github/tools/redundantptr/testdata/src/no-warnings/main.go:8:8: could not import github.com/google/go-github/v84/github (invalid package name: "")
analysistest.go:431: error analyzing redundantptr@has-warnings: analysis skipped due to errors in package
analysistest.go:431: error analyzing redundantptr@no-warnings: analysis skipped due to errors in package
FAIL
FAIL tools/redundantptr 0.379s
FAILThe analysistest framework needs the imported packages to be available in the testdata directory structure.
| 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 | ||
| ) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @alexandear and @Not-Dhananjay-Mishra!
LGTM.
Merging.
This PR adds
redundantptrlinter to detectgithub.Ptr(x)calls that can be replaced with simple&x.