Fixed crashing without arguments

This commit is contained in:
raul 2024-02-12 12:04:28 +00:00
parent 92d4ff62f3
commit ca05ff2eba
2 changed files with 4 additions and 6 deletions

BIN
golangr/file-reader/file-reader Executable file

Binary file not shown.

View File

@ -8,8 +8,6 @@ import (
"strconv"
"strings"
"time"
//"time"
//"strconv"
)
type PlayerStats struct {
@ -26,8 +24,8 @@ var names = []string{}
var err error
var guess string
var guessLetter rune
var filePath string = os.Args[1]
var randWord string = getWord(filePath)
var filePath string
var randWord string
var hiddenChars []string
func scanLine() (line string) {
@ -43,6 +41,8 @@ func main() {
fmt.Println("Usage: ./file-reader names.txt")
os.Exit(1)
}
filePath = os.Args[1]
randWord = getWord(filePath)
for range randWord {
hiddenChars = append(hiddenChars, "_")
@ -91,8 +91,6 @@ func gameStatus() {
func game() {
clear()
//filePath := os.Args[1]
//randWord := getWord(filePath)
for {
gameStatus()
if player.lives < 0 {