remove pointers for optionality -- shockingly easy

This commit is contained in:
Ben Kraft
2021-03-22 17:39:22 -07:00
parent fed38e4f55
commit 463e3ed319
16 changed files with 39 additions and 38 deletions
+2 -2
View File
@@ -52,13 +52,13 @@ func Main() {
if err != nil {
return
}
fmt.Println("you are", *viewerResp.Viewer.MyName)
fmt.Println("you are", viewerResp.Viewer.MyName)
userResp, err := getUser(context.Background(), graphqlClient, username)
if err != nil {
return
}
fmt.Println(username, "is", *userResp.User.TheirName)
fmt.Println(username, "is", userResp.User.TheirName)
}
//go:generate go run github.com/Khan/genql genql.yaml
+3 -3
View File
@@ -9,11 +9,11 @@ import (
)
type GetUserResponse struct {
User *GetUserUser `json:"user"`
User GetUserUser `json:"user"`
}
type GetUserUser struct {
TheirName *string `json:"theirName"`
TheirName string `json:"theirName"`
}
type GetViewerResponse struct {
@@ -21,7 +21,7 @@ type GetViewerResponse struct {
}
type GetViewerViewerUser struct {
MyName *string
MyName string
}
func getViewer(ctx context.Context, client *graphql.Client) (*GetViewerResponse, error) {