Go std lib是否具有将cv文件读入map [string] string的功能?

I'd like to read a csv file from disk into a, []map[string]string datatype. Where the []slice is the line number and map["key"] is the header (line 1) of the csv file.

I could not find anything in the standard library to accomplish this.

Based on reply, it sounds like there is nothing in the standard libraries, like ioutil, to read a csv file into a map.

The following function given a path to a csv file will convert it into a slice of map[string]string.

package main

import (
    "os"
"encoding/csv"
    "fmt"
"strings"
)



 // CSVFileToMap  reads csv file into slice of map
    func CSVFileToMap(filePath string) (returnMap []map[string]string, err error) {

    // read csv file
    csvfile, err := os.Open(filePath)
    if err != nil {
        return nil, fmt.Errorf(err.Error())
    }

    defer csvfile.Close()

    reader := csv.NewReader(csvfile)

    rawCSVdata, err := reader.ReadAll()
    if err != nil {
        return nil, fmt.Errorf(err.Error())
    }

    header := []string{} // holds first row (header)
    for lineNum, record := range rawCSVdata {

        // for first row, build the header slice
        if lineNum == 0 {
            for i := 0; i < len(record); i++ {
                header = append(header, strings.TrimSpace(record[i]))
            }
        } else {
            // for each cell, map[string]string k=header v=value
            line := map[string]string{}
            for i := 0; i < len(record); i++ {
                line[header[i]] = record[i]
            }
            returnMap = append(returnMap, line)
        }
    }

    return
}