Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/gohandson/gacha-ja

go 1.18
8 changes: 6 additions & 2 deletions skeleton/section05/step01/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func inputN(p *gacha.Player) int {

func saveResults(results []*gacha.Card) {
// TODO: results.txtというファイルを作成する

f, err := os.Create("results.txt")
if err != nil {
fmt.Println(err)
return
Expand All @@ -53,6 +53,7 @@ func saveResults(results []*gacha.Card) {

for _, result := range results {
// TODO: fmt.Fprintln関数を使ってresultをファイルに出力する
fmt.Fprintln(f, result)
}
}

Expand All @@ -66,7 +67,10 @@ func saveSummary(summary map[gacha.Rarity]int) {
defer func() {
// TODO: ファイルを閉じる
// エラー発生した場合はfmt.Println関数で出力する

err := f.Close()
if err != nil {
fmt.Println(err)
}
}()

for rarity, count := range summary {
Expand Down