Conversation
mf-sakura
reviewed
Apr 13, 2020
mf-sakura
left a comment
Owner
There was a problem hiding this comment.
@ookura-mf
概ね良さそうに思いました:+1:
エラーハンドリング周りで1点だけコメントしました。
Comment on lines
+73
to
+74
| err := userController.Update(*id, *firstName, *lastName) | ||
| if err != nil { |
Owner
There was a problem hiding this comment.
Goだと以下の様にする事が多いです。
1行になってシンプルになったり、変数のスコープがif文に狭まるのでメモリ効率が良いです。
Suggested change
| err := userController.Update(*id, *firstName, *lastName) | |
| if err != nil { | |
| if err := userController.Update(*id, *firstName, *lastName); err != nil { |
Author
There was a problem hiding this comment.
なるほど 👀
rubyだとifで代入するのは可読性が悪いので設定によってはlinterに怒られたりしますが、ここではerrに代入するだけなのでこの方が良さそうですね
Comment on lines
+42
to
+43
| _, err := tx.Exec("UPDATE users SET first_name = ?, last_name = ? WHERE id = ?", u.FirstName, u.LastName, u.ID) | ||
| if err != nil { |
Owner
There was a problem hiding this comment.
これも一つ目の戻り値を使わないのであれば、以下の方が良いと思います。
Suggested change
| _, err := tx.Exec("UPDATE users SET first_name = ?, last_name = ? WHERE id = ?", u.FirstName, u.LastName, u.ID) | |
| if err != nil { | |
| if _, err := tx.Exec("UPDATE users SET first_name = ?, last_name = ? WHERE id = ?", u.FirstName, u.LastName, u.ID); err !=nil{} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.