Skip to content

Commit f632d4b

Browse files
refactor: Use value types for required gist request fields
Per review, the required scalar fields on the gist request structs should be passed by value rather than by pointer: CreateGistFile.Content and the Body fields on CreateGistCommentRequest / UpdateGistCommentRequest are now string with json:"..." (no omitempty). Drop the redundant "(Required.)" doc notes now that the types convey it, and regenerate the accessors.
1 parent a332585 commit f632d4b

6 files changed

Lines changed: 22 additions & 29 deletions

File tree

‎github/gists.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (g Gist) String() string {
4141
type CreateGistRequest struct {
4242
Description *string `json:"description,omitempty"`
4343
Public *bool `json:"public,omitempty"`
44-
// Files is the set of files that make up the gist, keyed by filename. (Required.)
44+
// Files is the set of files that make up the gist, keyed by filename.
4545
Files map[GistFilename]*CreateGistFile `json:"files"`
4646
}
4747

@@ -73,8 +73,8 @@ func (g GistFile) String() string {
7373
// CreateGistFile represents a file within a CreateGistRequest, keyed by filename
7474
// in the request's Files map.
7575
type CreateGistFile struct {
76-
// Content is the contents of the file. (Required.)
77-
Content *string `json:"content,omitempty"`
76+
// Content is the contents of the file.
77+
Content string `json:"content"`
7878
}
7979

8080
// UpdateGistFile represents a file within an UpdateGistRequest, keyed by filename

‎github/gists_comments.go‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ func (g GistComment) String() string {
2525

2626
// CreateGistCommentRequest represents the input for creating a gist comment.
2727
type CreateGistCommentRequest struct {
28-
Body *string `json:"body,omitempty"`
28+
// Body is the comment text.
29+
Body string `json:"body"`
2930
}
3031

3132
// UpdateGistCommentRequest represents the input for updating a gist comment.
3233
type UpdateGistCommentRequest struct {
33-
Body *string `json:"body,omitempty"`
34+
// Body is the comment text.
35+
Body string `json:"body"`
3436
}
3537

3638
// ListComments lists all comments for a gist.

‎github/gists_comments_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func TestGistsService_CreateComment(t *testing.T) {
107107
t.Parallel()
108108
client, mux, _ := setup(t)
109109

110-
input := CreateGistCommentRequest{Body: Ptr("b")}
110+
input := CreateGistCommentRequest{Body: "b"}
111111

112112
mux.HandleFunc("/gists/1/comments", func(w http.ResponseWriter, r *http.Request) {
113113
testMethod(t, r, "POST")
@@ -154,7 +154,7 @@ func TestGistsService_UpdateComment(t *testing.T) {
154154
t.Parallel()
155155
client, mux, _ := setup(t)
156156

157-
input := UpdateGistCommentRequest{Body: Ptr("b")}
157+
input := UpdateGistCommentRequest{Body: "b"}
158158

159159
mux.HandleFunc("/gists/1/comments/2", func(w http.ResponseWriter, r *http.Request) {
160160
testMethod(t, r, "PATCH")

‎github/gists_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func TestGistsService_Create(t *testing.T) {
267267
Description: Ptr("Gist description"),
268268
Public: Ptr(false),
269269
Files: map[GistFilename]*CreateGistFile{
270-
"test.txt": {Content: Ptr("Gist file content")},
270+
"test.txt": {Content: "Gist file content"},
271271
},
272272
}
273273

‎github/github-accessors.go‎

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎github/github-accessors_test.go‎

Lines changed: 3 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)