(header string)
| 40 | } |
| 41 | |
| 42 | func (r *TabReader) ParseHeader(header string) error { |
| 43 | if len(r.headers) == 0 { |
| 44 | return fmt.Errorf("no header") |
| 45 | } |
| 46 | for i := range r.headers { |
| 47 | start := strings.Index(header, r.headers[i]) |
| 48 | if start == -1 { |
| 49 | return fmt.Errorf("header %q not matched", r.headers[i]) |
| 50 | } |
| 51 | if i > 0 { |
| 52 | r.indexs[r.headers[i-1]].end = start |
| 53 | } |
| 54 | r.indexs[r.headers[i]] = &headerIndex{start, -1} |
| 55 | } |
| 56 | return nil |
| 57 | } |
| 58 | |
| 59 | func (r *TabReader) ReadRow(row, key string) (string, bool) { |
| 60 | idx, ok := r.indexs[key] |
no outgoing calls