-
Notifications
You must be signed in to change notification settings - Fork 17
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
Kadai3-1 uobikiemukot #47
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コメントしましたので、参考にしていただければと思います
|
||
// ReadInput read io.Reader and return string channel | ||
func ReadInput(ctx context.Context, in io.Reader) <-chan string { | ||
ch := make(chan string, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size 0の場合は特に指定なしでも問題ありません
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: 33fc2e4
kadai3-1/uobikiemukot/main.go
Outdated
|
||
func main() { | ||
bg := context.Background() | ||
ctx, cancel := context.WithCancel(bg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer cancel
は呼び忘れないようにしましょう
https://golang.org/pkg/context/
Failing to call the CancelFunc leaks the child and its children until the parent is canceled or the timer fires.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: 01f9a44
go func() { | ||
defer close(ch) | ||
sc := bufio.NewScanner(in) | ||
for sc.Scan() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bufio.NewScanner
で os.Stdin
を渡しているため、 sc.Scan
は標準入力でenterが入力するまでブロックします
そして、下記の箇所でinputのみを待ってしまうために、なにもせず5秒経過したとしても0問正解として終わらず、その後に入力されたひとつ目の入力を受け付けてしまいます
https://github.com/gopherdojo/dojo4/pull/47/files#diff-4d4d5b583e35d4c540d67179051f4406R29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed: ff5211e
レビューありがとうございました。 |
課題3-1
時間が足りず、最低限のものしかできていません 😿