package oplcli import ( "bufio" "fmt" "log/slog" "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) lineNum := 0 scanner := bufio.NewScanner(file) for scanner.Scan() { line := scanner.Text() lineNum++ substrings := strings.SplitN(line, " ", 2) if len(substrings) != 2 { slog.Warn("Line in gamelist is malformed", "line", lineNum) continue } key := substrings[0] value := substrings[1] gameList[key] = value } return gameList, nil }