diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-05-28 22:48:03 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-05-28 22:48:03 +0200 |
commit | 12b3219daf446f385ce574ee8ab71a596bf201fc (patch) | |
tree | e5d66948d85fa642b88f3f3a624c2814cc503145 /skate | |
parent | b1c8cd2d91f611bc5432e9ec3451196b9465d26b (diff) | |
download | refcat-12b3219daf446f385ce574ee8ab71a596bf201fc.tar.gz refcat-12b3219daf446f385ce574ee8ab71a596bf201fc.zip |
xio: tabs docs
Diffstat (limited to 'skate')
-rw-r--r-- | skate/xio/util.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/skate/xio/util.go b/skate/xio/util.go index ead1a5d..de3afb4 100644 --- a/skate/xio/util.go +++ b/skate/xio/util.go @@ -19,6 +19,7 @@ func OpenTwo(f1, f2 string) (g1, g2 *os.File, err error) { return g1, g2, nil } +// TabsToMapFile turns columns from a file into a map. func TabsToMapFile(filename, sep string, kCol, vCol int) (map[string]string, error) { f, err := os.Open(filename) if err != nil { @@ -28,12 +29,12 @@ func TabsToMapFile(filename, sep string, kCol, vCol int) (map[string]string, err return TabsToMap(f, sep, kCol, vCol) } -// TabsToMap read from a reader and turns values from kCol, vCol columns into a -// mapping. +// TabsToMap read from a reader and turns values from kCol, vCol columns +// (1-indexed) into a map. func TabsToMap(r io.Reader, sep string, kCol, vCol int) (map[string]string, error) { var ( br = bufio.NewReader(r) - m = make(map[string]string, 8388608) + m = make(map[string]string) line, k, v string fields []string err error |