Skip to content

Kadai3-1 uobikiemukot - #47

Open
uobikiemukot wants to merge 8 commits into
masterfrom
kadai3-1-uobikiemukot
Open

Kadai3-1 uobikiemukot#47
uobikiemukot wants to merge 8 commits into
masterfrom
kadai3-1-uobikiemukot

Conversation

@uobikiemukot

@uobikiemukot uobikiemukot commented Nov 26, 2018

Copy link
Copy Markdown
Contributor

課題3-1

  • タイピングゲームを作ろう
    • 標準出力に英単語を出す(出すものは自由)
    • 標準入力から1行受け取る
    • 制限時間内に何問解けたか表示する

時間が足りず、最低限のものしかできていません 😿

@mizkei mizkei left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

コメントしましたので、参考にしていただければと思います

Comment thread kadai3-1/uobikiemukot/typing/typing.go Outdated

// ReadInput read io.Reader and return string channel
func ReadInput(ctx context.Context, in io.Reader) <-chan string {
ch := make(chan string, 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

size 0の場合は特に指定なしでも問題ありません

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed: 33fc2e4

Comment thread kadai3-1/uobikiemukot/main.go Outdated

func main() {
bg := context.Background()
ctx, cancel := context.WithCancel(bg)

Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed: 01f9a44

Comment thread kadai3-1/uobikiemukot/typing/typing.go Outdated
go func() {
defer close(ch)
sc := bufio.NewScanner(in)
for sc.Scan() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bufio.NewScanneros.Stdin を渡しているため、 sc.Scan は標準入力でenterが入力するまでブロックします
そして、下記の箇所でinputのみを待ってしまうために、なにもせず5秒経過したとしても0問正解として終わらず、その後に入力されたひとつ目の入力を受け付けてしまいます
https://github.com/gopherdojo/dojo4/pull/47/files#diff-4d4d5b583e35d4c540d67179051f4406R29

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed: ff5211e

@uobikiemukot uobikiemukot added the kadai3 課題3 label Dec 6, 2018
@uobikiemukot

Copy link
Copy Markdown
Contributor Author

レビューありがとうございました。
ちょこっと指摘箇所を修正しました。

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

Labels

kadai3 課題3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants