package oplcli import ( "bufio" "fmt" "os" "strings" ) func loadGamelist(filepath string) (map[string]string, error) { file, err := os.Open(filepath) if err != nil { return nil, fmt.Errorf("Failed to open file: %w", err) } defer file.Close() gameList := make(map[string]string) scanner := bufio.NewScanner(file) for scanner.Scan() { line := scanner.Text() substrings := strings.SplitN(line, " ", 2) if len(substrings) != 2 { // TODO: something in the gamelist file is not formatted right fmt.Printf("Malformed: %s\n", line) continue } key := substrings[0] value := substrings[1] gameList[key] = value } return gameList, nil }