Skip to content

Commit 879c78f

Browse files
authored
chore: Use go:fix inline for deprecated ptr funcs (#4034)
1 parent 6252d35 commit 879c78f

File tree

5 files changed

+32
-24
lines changed

5 files changed

+32
-24
lines changed

github/enterprise_apps_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestEnterpriseService_UpdateAppInstallationRepositories(t *testing.T) {
5151
client, mux, _ := setup(t)
5252

5353
input := UpdateAppInstallationRepositoriesOptions{
54-
RepositorySelection: String("selected"),
54+
RepositorySelection: Ptr("selected"),
5555
SelectedRepositoryIDs: []int64{1, 2},
5656
}
5757

github/github.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,25 +1791,33 @@ func Ptr[T any](v T) *T {
17911791
// to store v and returns a pointer to it.
17921792
//
17931793
// Deprecated: use Ptr instead.
1794-
func Bool(v bool) *bool { return &v }
1794+
//
1795+
//go:fix inline
1796+
func Bool(v bool) *bool { return Ptr(v) }
17951797

17961798
// Int is a helper routine that allocates a new int value
17971799
// to store v and returns a pointer to it.
17981800
//
17991801
// Deprecated: use Ptr instead.
1800-
func Int(v int) *int { return &v }
1802+
//
1803+
//go:fix inline
1804+
func Int(v int) *int { return Ptr(v) }
18011805

18021806
// Int64 is a helper routine that allocates a new int64 value
18031807
// to store v and returns a pointer to it.
18041808
//
18051809
// Deprecated: use Ptr instead.
1806-
func Int64(v int64) *int64 { return &v }
1810+
//
1811+
//go:fix inline
1812+
func Int64(v int64) *int64 { return Ptr(v) }
18071813

18081814
// String is a helper routine that allocates a new string value
18091815
// to store v and returns a pointer to it.
18101816
//
18111817
// Deprecated: use Ptr instead.
1812-
func String(v string) *string { return &v }
1818+
//
1819+
//go:fix inline
1820+
func String(v string) *string { return Ptr(v) }
18131821

18141822
// roundTripperFunc creates a RoundTripper (transport).
18151823
type roundTripperFunc func(*http.Request) (*http.Response, error)

github/orgs_custom_repository_roles_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,21 @@ func TestOrganizationsService_GetCustomRepoRole(t *testing.T) {
130130
}
131131

132132
want := &CustomRepoRoles{
133-
ID: Int64(1),
134-
Name: String("Developer"),
135-
BaseRole: String("write"),
133+
ID: Ptr(int64(1)),
134+
Name: Ptr("Developer"),
135+
BaseRole: Ptr("write"),
136136
Permissions: []string{"delete_alerts_code_scanning"},
137137
Org: &Organization{
138-
Login: String("l"),
139-
ID: Int64(1),
140-
NodeID: String("n"),
141-
AvatarURL: String("a"),
142-
HTMLURL: String("h"),
143-
Name: String("n"),
144-
Company: String("c"),
145-
Blog: String("b"),
146-
Location: String("l"),
147-
Email: String("e"),
138+
Login: Ptr("l"),
139+
ID: Ptr(int64(1)),
140+
NodeID: Ptr("n"),
141+
AvatarURL: Ptr("a"),
142+
HTMLURL: Ptr("h"),
143+
Name: Ptr("n"),
144+
Company: Ptr("c"),
145+
Blog: Ptr("b"),
146+
Location: Ptr("l"),
147+
Email: Ptr("e"),
148148
},
149149
CreatedAt: &Timestamp{time.Date(2024, time.July, 21, 19, 33, 8, 0, time.UTC)},
150150
UpdatedAt: &Timestamp{time.Date(2024, time.July, 21, 19, 33, 8, 0, time.UTC)},

github/scim_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ func TestSCIMUserRole_Marshal(t *testing.T) {
491491

492492
testJSONMarshal(t, &SCIMUserRole{
493493
Value: "enterprise_owner",
494-
Primary: Bool(true),
494+
Primary: Ptr(true),
495495
}, `{
496496
"value": "enterprise_owner",
497497
"primary": true

github/sub_issue_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestSubIssuesService_Add(t *testing.T) {
3838
t.Errorf("SubIssues.Add returned error: %v", err)
3939
}
4040

41-
want := &SubIssue{Number: Ptr(1), ID: Int64(42)}
41+
want := &SubIssue{Number: Ptr(1), ID: Ptr(int64(42))}
4242
if !cmp.Equal(got, want) {
4343
t.Errorf("SubIssues.Add = %+v, want %+v", got, want)
4444
}
@@ -77,7 +77,7 @@ func TestSubIssuesService_ListByIssue(t *testing.T) {
7777
t.Errorf("SubIssues.ListByIssue returned error: %v", err)
7878
}
7979

80-
want := []*SubIssue{{ID: Int64(1)}, {ID: Int64(2)}}
80+
want := []*SubIssue{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}}
8181
if !cmp.Equal(issues, want) {
8282
t.Errorf("SubIssues.ListByIssue = %+v, want %+v", issues, want)
8383
}
@@ -121,7 +121,7 @@ func TestSubIssuesService_Remove(t *testing.T) {
121121
t.Errorf("SubIssues.Remove returned error: %v", err)
122122
}
123123

124-
want := &SubIssue{ID: Int64(42), Number: Ptr(1)}
124+
want := &SubIssue{ID: Ptr(int64(42)), Number: Ptr(1)}
125125
if !cmp.Equal(got, want) {
126126
t.Errorf("SubIssues.Remove = %+v, want %+v", got, want)
127127
}
@@ -140,7 +140,7 @@ func TestSubIssuesService_Reprioritize(t *testing.T) {
140140
t.Parallel()
141141
client, mux, _ := setup(t)
142142

143-
input := &SubIssueRequest{SubIssueID: 42, AfterID: Int64(5)}
143+
input := &SubIssueRequest{SubIssueID: 42, AfterID: Ptr(int64(5))}
144144

145145
mux.HandleFunc("/repos/o/r/issues/1/sub_issues/priority", func(w http.ResponseWriter, r *http.Request) {
146146
testMethod(t, r, "PATCH")
@@ -162,7 +162,7 @@ func TestSubIssuesService_Reprioritize(t *testing.T) {
162162
t.Errorf("SubIssues.Reprioritize returned error: %v", err)
163163
}
164164

165-
want := &SubIssue{ID: Int64(42), Number: Ptr(1)}
165+
want := &SubIssue{ID: Ptr(int64(42)), Number: Ptr(1)}
166166
if !cmp.Equal(got, want) {
167167
t.Errorf("SubIssues.Reprioritize = %+v, want %+v", got, want)
168168
}

0 commit comments

Comments
 (0)