Skip to content

Go勉強会第5回課題 #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

toru-taniguchi
Copy link

意味のあるもの作れる課題になってきて楽しい

database_sql (class5_task) $ make build
go build -o bin/database_sql
database_sql (class5_task) $ ./bin/database_sql -a indexID: 1, FirstName: aaa, LastName: iii
database_sql (class5_task) $ ./bin/database_sql -a update -i 1 -f hoge -l fuga
ID: 1, FirstName: hoge, LastName: fuga
database_sql (class5_task) $ ./bin/database_sql -a indexID: 1, FirstName: hoge, LastName: fuga

@toru-taniguchi toru-taniguchi changed the title ユーザーの更新ができるようにした Go勉強会第5回課題 Apr 8, 2020
Copy link
Owner

@mf-sakura mf-sakura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@toru-taniguchi
LGTM:+1:

@@ -18,6 +18,27 @@ func NewUserController(db *sql.DB) *UserController {
return &UserController{db: db}
}

// Update is a function for updating a user.
func (controller *UserController) Update(id string, firstName string, lastName string) (err error) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Named Return Value使えてて良い感じです。

Comment on lines 14 to 18
if err != nil {
return
}

return
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Named Return Valueでdb.Execのタイミングでerrに値が入るので、if文が不要だったりします。
これも好みですが、こういう選択肢もあるよという事で。

Suggested change
if err != nil {
return
}
return
return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants