-
Notifications
You must be signed in to change notification settings - Fork 2
kadai3-1-pei #27
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
base: master
Are you sure you want to change the base?
kadai3-1-pei #27
Conversation
wr := &wordsreader.WordsReader{FileName: "./textdata/words.txt"} | ||
words, err := wr.Read() | ||
if err != nil { | ||
return ExitCodeError |
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.
これだとどういうエラーが起きたのか分からないのでは?
kadai3-1/pei/main.go
Outdated
typingCh := typing.Question(words) | ||
timerCh := time.After(5 * time.Second) | ||
|
||
counter := 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.
ゼロ値でよい
fmt.Println("End Typing Game!") | ||
return ExitCodeOK | ||
} | ||
} |
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.
returnなくて動きます?
word := words[rand.Intn(len(words))] | ||
fmt.Println(word) | ||
|
||
stdin.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.
エラー処理は?
defer fp.Close() | ||
|
||
scanner := bufio.NewScanner(fp) | ||
for scanner.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.
エラー処理
|
||
// Read file | ||
func (wr WordsReader) Read() ([]string, error) { | ||
words := make([]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.
var words []string
で十分
t.Run(c.fileName, func(t *testing.T) { | ||
t.Parallel() | ||
wr := WordsReader{FileName: c.fileName} | ||
if actual, _ := wr.Read(); !reflect.DeepEqual(c.expected, actual) { |
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.
テストであってもエラー処理を省かない。
課題3-1 タイピングゲームを作ろう
TODO