Skip to content

Commit 4ba4058

Browse files
committed
replace []Issue with []*Issue and for other large structs as well
Note that this is an API-breaking change but should have minimal impact on users of this package due to the nice inference properties of the Go programming language. Fixes #180. Change-Id: Ib386135e6b8f306d1f54278968c576f3ceccc4e7
1 parent b240c2d commit 4ba4058

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+262
-262
lines changed

github/activity_events.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (e *Event) Payload() (payload interface{}) {
8585
// ListEvents drinks from the firehose of all public events across GitHub.
8686
//
8787
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-public-events
88-
func (s *ActivityService) ListEvents(opt *ListOptions) ([]Event, *Response, error) {
88+
func (s *ActivityService) ListEvents(opt *ListOptions) ([]*Event, *Response, error) {
8989
u, err := addOptions("events", opt)
9090
if err != nil {
9191
return nil, nil, err
@@ -96,7 +96,7 @@ func (s *ActivityService) ListEvents(opt *ListOptions) ([]Event, *Response, erro
9696
return nil, nil, err
9797
}
9898

99-
events := new([]Event)
99+
events := new([]*Event)
100100
resp, err := s.client.Do(req, events)
101101
if err != nil {
102102
return nil, resp, err
@@ -108,7 +108,7 @@ func (s *ActivityService) ListEvents(opt *ListOptions) ([]Event, *Response, erro
108108
// ListRepositoryEvents lists events for a repository.
109109
//
110110
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-repository-events
111-
func (s *ActivityService) ListRepositoryEvents(owner, repo string, opt *ListOptions) ([]Event, *Response, error) {
111+
func (s *ActivityService) ListRepositoryEvents(owner, repo string, opt *ListOptions) ([]*Event, *Response, error) {
112112
u := fmt.Sprintf("repos/%v/%v/events", owner, repo)
113113
u, err := addOptions(u, opt)
114114
if err != nil {
@@ -120,7 +120,7 @@ func (s *ActivityService) ListRepositoryEvents(owner, repo string, opt *ListOpti
120120
return nil, nil, err
121121
}
122122

123-
events := new([]Event)
123+
events := new([]*Event)
124124
resp, err := s.client.Do(req, events)
125125
if err != nil {
126126
return nil, resp, err
@@ -132,7 +132,7 @@ func (s *ActivityService) ListRepositoryEvents(owner, repo string, opt *ListOpti
132132
// ListIssueEventsForRepository lists issue events for a repository.
133133
//
134134
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository
135-
func (s *ActivityService) ListIssueEventsForRepository(owner, repo string, opt *ListOptions) ([]Event, *Response, error) {
135+
func (s *ActivityService) ListIssueEventsForRepository(owner, repo string, opt *ListOptions) ([]*Event, *Response, error) {
136136
u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo)
137137
u, err := addOptions(u, opt)
138138
if err != nil {
@@ -144,7 +144,7 @@ func (s *ActivityService) ListIssueEventsForRepository(owner, repo string, opt *
144144
return nil, nil, err
145145
}
146146

147-
events := new([]Event)
147+
events := new([]*Event)
148148
resp, err := s.client.Do(req, events)
149149
if err != nil {
150150
return nil, resp, err
@@ -156,7 +156,7 @@ func (s *ActivityService) ListIssueEventsForRepository(owner, repo string, opt *
156156
// ListEventsForRepoNetwork lists public events for a network of repositories.
157157
//
158158
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories
159-
func (s *ActivityService) ListEventsForRepoNetwork(owner, repo string, opt *ListOptions) ([]Event, *Response, error) {
159+
func (s *ActivityService) ListEventsForRepoNetwork(owner, repo string, opt *ListOptions) ([]*Event, *Response, error) {
160160
u := fmt.Sprintf("networks/%v/%v/events", owner, repo)
161161
u, err := addOptions(u, opt)
162162
if err != nil {
@@ -168,7 +168,7 @@ func (s *ActivityService) ListEventsForRepoNetwork(owner, repo string, opt *List
168168
return nil, nil, err
169169
}
170170

171-
events := new([]Event)
171+
events := new([]*Event)
172172
resp, err := s.client.Do(req, events)
173173
if err != nil {
174174
return nil, resp, err
@@ -180,7 +180,7 @@ func (s *ActivityService) ListEventsForRepoNetwork(owner, repo string, opt *List
180180
// ListEventsForOrganization lists public events for an organization.
181181
//
182182
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization
183-
func (s *ActivityService) ListEventsForOrganization(org string, opt *ListOptions) ([]Event, *Response, error) {
183+
func (s *ActivityService) ListEventsForOrganization(org string, opt *ListOptions) ([]*Event, *Response, error) {
184184
u := fmt.Sprintf("orgs/%v/events", org)
185185
u, err := addOptions(u, opt)
186186
if err != nil {
@@ -192,7 +192,7 @@ func (s *ActivityService) ListEventsForOrganization(org string, opt *ListOptions
192192
return nil, nil, err
193193
}
194194

195-
events := new([]Event)
195+
events := new([]*Event)
196196
resp, err := s.client.Do(req, events)
197197
if err != nil {
198198
return nil, resp, err
@@ -205,7 +205,7 @@ func (s *ActivityService) ListEventsForOrganization(org string, opt *ListOptions
205205
// true, only public events will be returned.
206206
//
207207
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user
208-
func (s *ActivityService) ListEventsPerformedByUser(user string, publicOnly bool, opt *ListOptions) ([]Event, *Response, error) {
208+
func (s *ActivityService) ListEventsPerformedByUser(user string, publicOnly bool, opt *ListOptions) ([]*Event, *Response, error) {
209209
var u string
210210
if publicOnly {
211211
u = fmt.Sprintf("users/%v/events/public", user)
@@ -222,7 +222,7 @@ func (s *ActivityService) ListEventsPerformedByUser(user string, publicOnly bool
222222
return nil, nil, err
223223
}
224224

225-
events := new([]Event)
225+
events := new([]*Event)
226226
resp, err := s.client.Do(req, events)
227227
if err != nil {
228228
return nil, resp, err
@@ -235,7 +235,7 @@ func (s *ActivityService) ListEventsPerformedByUser(user string, publicOnly bool
235235
// true, only public events will be returned.
236236
//
237237
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received
238-
func (s *ActivityService) ListEventsReceivedByUser(user string, publicOnly bool, opt *ListOptions) ([]Event, *Response, error) {
238+
func (s *ActivityService) ListEventsReceivedByUser(user string, publicOnly bool, opt *ListOptions) ([]*Event, *Response, error) {
239239
var u string
240240
if publicOnly {
241241
u = fmt.Sprintf("users/%v/received_events/public", user)
@@ -252,7 +252,7 @@ func (s *ActivityService) ListEventsReceivedByUser(user string, publicOnly bool,
252252
return nil, nil, err
253253
}
254254

255-
events := new([]Event)
255+
events := new([]*Event)
256256
resp, err := s.client.Do(req, events)
257257
if err != nil {
258258
return nil, resp, err
@@ -265,7 +265,7 @@ func (s *ActivityService) ListEventsReceivedByUser(user string, publicOnly bool,
265265
// must be authenticated as the user to view this.
266266
//
267267
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-events-for-an-organization
268-
func (s *ActivityService) ListUserEventsForOrganization(org, user string, opt *ListOptions) ([]Event, *Response, error) {
268+
func (s *ActivityService) ListUserEventsForOrganization(org, user string, opt *ListOptions) ([]*Event, *Response, error) {
269269
u := fmt.Sprintf("users/%v/events/orgs/%v", user, org)
270270
u, err := addOptions(u, opt)
271271
if err != nil {
@@ -277,7 +277,7 @@ func (s *ActivityService) ListUserEventsForOrganization(org, user string, opt *L
277277
return nil, nil, err
278278
}
279279

280-
events := new([]Event)
280+
events := new([]*Event)
281281
resp, err := s.client.Do(req, events)
282282
if err != nil {
283283
return nil, resp, err

github/activity_events_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestActivityService_ListEvents(t *testing.T) {
3131
t.Errorf("Activities.ListEvents returned error: %v", err)
3232
}
3333

34-
want := []Event{{ID: String("1")}, {ID: String("2")}}
34+
want := []*Event{{ID: String("1")}, {ID: String("2")}}
3535
if !reflect.DeepEqual(events, want) {
3636
t.Errorf("Activities.ListEvents returned %+v, want %+v", events, want)
3737
}
@@ -55,7 +55,7 @@ func TestActivityService_ListRepositoryEvents(t *testing.T) {
5555
t.Errorf("Activities.ListRepositoryEvents returned error: %v", err)
5656
}
5757

58-
want := []Event{{ID: String("1")}, {ID: String("2")}}
58+
want := []*Event{{ID: String("1")}, {ID: String("2")}}
5959
if !reflect.DeepEqual(events, want) {
6060
t.Errorf("Activities.ListRepositoryEvents returned %+v, want %+v", events, want)
6161
}
@@ -84,7 +84,7 @@ func TestActivityService_ListIssueEventsForRepository(t *testing.T) {
8484
t.Errorf("Activities.ListIssueEventsForRepository returned error: %v", err)
8585
}
8686

87-
want := []Event{{ID: String("1")}, {ID: String("2")}}
87+
want := []*Event{{ID: String("1")}, {ID: String("2")}}
8888
if !reflect.DeepEqual(events, want) {
8989
t.Errorf("Activities.ListIssueEventsForRepository returned %+v, want %+v", events, want)
9090
}
@@ -113,7 +113,7 @@ func TestActivityService_ListEventsForRepoNetwork(t *testing.T) {
113113
t.Errorf("Activities.ListEventsForRepoNetwork returned error: %v", err)
114114
}
115115

116-
want := []Event{{ID: String("1")}, {ID: String("2")}}
116+
want := []*Event{{ID: String("1")}, {ID: String("2")}}
117117
if !reflect.DeepEqual(events, want) {
118118
t.Errorf("Activities.ListEventsForRepoNetwork returned %+v, want %+v", events, want)
119119
}
@@ -142,7 +142,7 @@ func TestActivityService_ListEventsForOrganization(t *testing.T) {
142142
t.Errorf("Activities.ListEventsForOrganization returned error: %v", err)
143143
}
144144

145-
want := []Event{{ID: String("1")}, {ID: String("2")}}
145+
want := []*Event{{ID: String("1")}, {ID: String("2")}}
146146
if !reflect.DeepEqual(events, want) {
147147
t.Errorf("Activities.ListEventsForOrganization returned %+v, want %+v", events, want)
148148
}
@@ -171,7 +171,7 @@ func TestActivityService_ListEventsPerformedByUser_all(t *testing.T) {
171171
t.Errorf("Events.ListPerformedByUser returned error: %v", err)
172172
}
173173

174-
want := []Event{{ID: String("1")}, {ID: String("2")}}
174+
want := []*Event{{ID: String("1")}, {ID: String("2")}}
175175
if !reflect.DeepEqual(events, want) {
176176
t.Errorf("Events.ListPerformedByUser returned %+v, want %+v", events, want)
177177
}
@@ -191,7 +191,7 @@ func TestActivityService_ListEventsPerformedByUser_publicOnly(t *testing.T) {
191191
t.Errorf("Events.ListPerformedByUser returned error: %v", err)
192192
}
193193

194-
want := []Event{{ID: String("1")}, {ID: String("2")}}
194+
want := []*Event{{ID: String("1")}, {ID: String("2")}}
195195
if !reflect.DeepEqual(events, want) {
196196
t.Errorf("Events.ListPerformedByUser returned %+v, want %+v", events, want)
197197
}
@@ -220,7 +220,7 @@ func TestActivityService_ListEventsReceivedByUser_all(t *testing.T) {
220220
t.Errorf("Events.ListReceivedByUser returned error: %v", err)
221221
}
222222

223-
want := []Event{{ID: String("1")}, {ID: String("2")}}
223+
want := []*Event{{ID: String("1")}, {ID: String("2")}}
224224
if !reflect.DeepEqual(events, want) {
225225
t.Errorf("Events.ListReceivedUser returned %+v, want %+v", events, want)
226226
}
@@ -240,7 +240,7 @@ func TestActivityService_ListEventsReceivedByUser_publicOnly(t *testing.T) {
240240
t.Errorf("Events.ListReceivedByUser returned error: %v", err)
241241
}
242242

243-
want := []Event{{ID: String("1")}, {ID: String("2")}}
243+
want := []*Event{{ID: String("1")}, {ID: String("2")}}
244244
if !reflect.DeepEqual(events, want) {
245245
t.Errorf("Events.ListReceivedByUser returned %+v, want %+v", events, want)
246246
}
@@ -269,7 +269,7 @@ func TestActivityService_ListUserEventsForOrganization(t *testing.T) {
269269
t.Errorf("Activities.ListUserEventsForOrganization returned error: %v", err)
270270
}
271271

272-
want := []Event{{ID: String("1")}, {ID: String("2")}}
272+
want := []*Event{{ID: String("1")}, {ID: String("2")}}
273273
if !reflect.DeepEqual(events, want) {
274274
t.Errorf("Activities.ListUserEventsForOrganization returned %+v, want %+v", events, want)
275275
}

github/activity_notifications.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type NotificationListOptions struct {
4949
// ListNotifications lists all notifications for the authenticated user.
5050
//
5151
// GitHub API Docs: https://developer.github.com/v3/activity/notifications/#list-your-notifications
52-
func (s *ActivityService) ListNotifications(opt *NotificationListOptions) ([]Notification, *Response, error) {
52+
func (s *ActivityService) ListNotifications(opt *NotificationListOptions) ([]*Notification, *Response, error) {
5353
u := fmt.Sprintf("notifications")
5454
u, err := addOptions(u, opt)
5555
if err != nil {
@@ -61,7 +61,7 @@ func (s *ActivityService) ListNotifications(opt *NotificationListOptions) ([]Not
6161
return nil, nil, err
6262
}
6363

64-
var notifications []Notification
64+
var notifications []*Notification
6565
resp, err := s.client.Do(req, &notifications)
6666
if err != nil {
6767
return nil, resp, err
@@ -74,7 +74,7 @@ func (s *ActivityService) ListNotifications(opt *NotificationListOptions) ([]Not
7474
// for the authenticated user.
7575
//
7676
// GitHub API Docs: https://developer.github.com/v3/activity/notifications/#list-your-notifications-in-a-repository
77-
func (s *ActivityService) ListRepositoryNotifications(owner, repo string, opt *NotificationListOptions) ([]Notification, *Response, error) {
77+
func (s *ActivityService) ListRepositoryNotifications(owner, repo string, opt *NotificationListOptions) ([]*Notification, *Response, error) {
7878
u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo)
7979
u, err := addOptions(u, opt)
8080
if err != nil {
@@ -86,7 +86,7 @@ func (s *ActivityService) ListRepositoryNotifications(owner, repo string, opt *N
8686
return nil, nil, err
8787
}
8888

89-
var notifications []Notification
89+
var notifications []*Notification
9090
resp, err := s.client.Do(req, &notifications)
9191
if err != nil {
9292
return nil, resp, err

github/activity_notifications_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestActivityService_ListNotification(t *testing.T) {
4141
t.Errorf("Activity.ListNotifications returned error: %v", err)
4242
}
4343

44-
want := []Notification{{ID: String("1"), Subject: &NotificationSubject{Title: String("t")}}}
44+
want := []*Notification{{ID: String("1"), Subject: &NotificationSubject{Title: String("t")}}}
4545
if !reflect.DeepEqual(notifications, want) {
4646
t.Errorf("Activity.ListNotifications returned %+v, want %+v", notifications, want)
4747
}
@@ -61,7 +61,7 @@ func TestActivityService_ListRepositoryNotification(t *testing.T) {
6161
t.Errorf("Activity.ListRepositoryNotifications returned error: %v", err)
6262
}
6363

64-
want := []Notification{{ID: String("1")}}
64+
want := []*Notification{{ID: String("1")}}
6565
if !reflect.DeepEqual(notifications, want) {
6666
t.Errorf("Activity.ListRepositoryNotifications returned %+v, want %+v", notifications, want)
6767
}

github/activity_star.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Stargazer struct {
2222
// ListStargazers lists people who have starred the specified repo.
2323
//
2424
// GitHub API Docs: https://developer.github.com/v3/activity/starring/#list-stargazers
25-
func (s *ActivityService) ListStargazers(owner, repo string, opt *ListOptions) ([]Stargazer, *Response, error) {
25+
func (s *ActivityService) ListStargazers(owner, repo string, opt *ListOptions) ([]*Stargazer, *Response, error) {
2626
u := fmt.Sprintf("repos/%s/%s/stargazers", owner, repo)
2727
u, err := addOptions(u, opt)
2828
if err != nil {
@@ -37,7 +37,7 @@ func (s *ActivityService) ListStargazers(owner, repo string, opt *ListOptions) (
3737
// TODO: remove custom Accept header when this API fully launches
3838
req.Header.Set("Accept", mediaTypeStarringPreview)
3939

40-
stargazers := new([]Stargazer)
40+
stargazers := new([]*Stargazer)
4141
resp, err := s.client.Do(req, stargazers)
4242
if err != nil {
4343
return nil, resp, err
@@ -64,7 +64,7 @@ type ActivityListStarredOptions struct {
6464
// will list the starred repositories for the authenticated user.
6565
//
6666
// GitHub API docs: http://developer.github.com/v3/activity/starring/#list-repositories-being-starred
67-
func (s *ActivityService) ListStarred(user string, opt *ActivityListStarredOptions) ([]StarredRepository, *Response, error) {
67+
func (s *ActivityService) ListStarred(user string, opt *ActivityListStarredOptions) ([]*StarredRepository, *Response, error) {
6868
var u string
6969
if user != "" {
7070
u = fmt.Sprintf("users/%v/starred", user)
@@ -84,7 +84,7 @@ func (s *ActivityService) ListStarred(user string, opt *ActivityListStarredOptio
8484
// TODO: remove custom Accept header when this API fully launches
8585
req.Header.Set("Accept", mediaTypeStarringPreview)
8686

87-
repos := new([]StarredRepository)
87+
repos := new([]*StarredRepository)
8888
resp, err := s.client.Do(req, repos)
8989
if err != nil {
9090
return nil, resp, err

github/activity_star_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestActivityService_ListStargazers(t *testing.T) {
3232
t.Errorf("Activity.ListStargazers returned error: %v", err)
3333
}
3434

35-
want := []Stargazer{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, User: &User{ID: Int(1)}}}
35+
want := []*Stargazer{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, User: &User{ID: Int(1)}}}
3636
if !reflect.DeepEqual(stargazers, want) {
3737
t.Errorf("Activity.ListStargazers returned %+v, want %+v", stargazers, want)
3838
}
@@ -53,7 +53,7 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) {
5353
t.Errorf("Activity.ListStarred returned error: %v", err)
5454
}
5555

56-
want := []StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int(1)}}}
56+
want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int(1)}}}
5757
if !reflect.DeepEqual(repos, want) {
5858
t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want)
5959
}
@@ -80,7 +80,7 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) {
8080
t.Errorf("Activity.ListStarred returned error: %v", err)
8181
}
8282

83-
want := []StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int(2)}}}
83+
want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int(2)}}}
8484
if !reflect.DeepEqual(repos, want) {
8585
t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want)
8686
}

github/activity_watching.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type Subscription struct {
2525
// ListWatchers lists watchers of a particular repo.
2626
//
2727
// GitHub API Docs: http://developer.github.com/v3/activity/watching/#list-watchers
28-
func (s *ActivityService) ListWatchers(owner, repo string, opt *ListOptions) ([]User, *Response, error) {
28+
func (s *ActivityService) ListWatchers(owner, repo string, opt *ListOptions) ([]*User, *Response, error) {
2929
u := fmt.Sprintf("repos/%s/%s/subscribers", owner, repo)
3030
u, err := addOptions(u, opt)
3131
if err != nil {
@@ -37,7 +37,7 @@ func (s *ActivityService) ListWatchers(owner, repo string, opt *ListOptions) ([]
3737
return nil, nil, err
3838
}
3939

40-
watchers := new([]User)
40+
watchers := new([]*User)
4141
resp, err := s.client.Do(req, watchers)
4242
if err != nil {
4343
return nil, resp, err
@@ -50,7 +50,7 @@ func (s *ActivityService) ListWatchers(owner, repo string, opt *ListOptions) ([]
5050
// the empty string will fetch watched repos for the authenticated user.
5151
//
5252
// GitHub API Docs: https://developer.github.com/v3/activity/watching/#list-repositories-being-watched
53-
func (s *ActivityService) ListWatched(user string, opt *ListOptions) ([]Repository, *Response, error) {
53+
func (s *ActivityService) ListWatched(user string, opt *ListOptions) ([]*Repository, *Response, error) {
5454
var u string
5555
if user != "" {
5656
u = fmt.Sprintf("users/%v/subscriptions", user)
@@ -67,7 +67,7 @@ func (s *ActivityService) ListWatched(user string, opt *ListOptions) ([]Reposito
6767
return nil, nil, err
6868
}
6969

70-
watched := new([]Repository)
70+
watched := new([]*Repository)
7171
resp, err := s.client.Do(req, watched)
7272
if err != nil {
7373
return nil, resp, err

0 commit comments

Comments
 (0)