Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Kadai3-1 uobikiemukot#47

Open
uobikiemukot wants to merge 8 commits into
master from
kadai3-1-uobikiemukot
Open

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

Conversation

@uobikiemukot

@uobikiemukot uobikiemukot commented Nov 26, 2018
edited
Loading

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の場合は特に指定なしでも問題ありません

@uobikiemukot uobikiemukot Dec 26, 2018

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.

@uobikiemukot uobikiemukot Dec 26, 2018

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

@uobikiemukot uobikiemukot Dec 26, 2018

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

Copy link
Copy Markdown
Contributor Author

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

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

Reviewers

1 more reviewer
@mizkei mizkei mizkei left review comments
Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

kadai3 課題3

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /