Kadai3-1 miyahara - #51
Open
hikaru7719 wants to merge 2 commits into
Open
Conversation
hikaru7719
force-pushed
the
kadai3-1-miyahara
branch
from
November 27, 2018 13:59
2b989b2 to
7ffa85e
Compare
mizkei
reviewed
Nov 30, 2018
mizkei
left a comment
There was a problem hiding this comment.
コメントしましたので、参考にしていただければと思います
gofmtはかけておいたほうが良いです
| for s.Scan(){ | ||
| select{ | ||
| case <- ctx.Done(): | ||
| close(ch) |
There was a problem hiding this comment.
これではcontextがcancelされなかった場合にcloseされないことになりますので(問題はないと思いますが)、閉じるのであれば、このfuncの最初に defer close(ch) しておいたほうが良いと思います
| fmt.Println("time up") | ||
| break LOOP | ||
| default: | ||
| typedString := <-ch |
There was a problem hiding this comment.
defaultの中にこの処理を書いてしまうと、ユーザの入力があるまでここでブロックしてしまいます
その場合、 ctx.Done() を待つことができないため、制限時間を超えてもユーザが入力を終えるまではゲームが終わらず、制限時間後の最後の入力も成否を判定する対象になってしまうため、同時に待てるようにしたほうが良いと思います
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.
遅くなりましたが、課題3-1です。