2022-01-10 05:11:15 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/csv"
|
|
|
|
"io"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
func loadMap(file string) (map[string]string, error) {
|
|
|
|
f, err := os.Open(file)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
m := make(map[string]string)
|
|
|
|
|
|
|
|
r := csv.NewReader(f)
|
|
|
|
|
2022-01-11 06:05:20 +00:00
|
|
|
r.Comma = '|'
|
|
|
|
|
2022-01-10 05:11:15 +00:00
|
|
|
for {
|
|
|
|
row, err := r.Read()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err == io.EOF {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-04-01 02:04:19 +00:00
|
|
|
m[row[0]] = row[1]
|
2022-01-10 05:11:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m, nil
|
|
|
|
}
|