HasColumns reports whether every named column is present in the header.
(cols ...string)
| 93 | |
| 94 | // HasColumns reports whether every named column is present in the header. |
| 95 | func (t *Table) HasColumns(cols ...string) bool { |
| 96 | set := make(map[string]struct{}, len(t.Header)) |
| 97 | for _, h := range t.Header { |
| 98 | set[strings.TrimSpace(h)] = struct{}{} |
| 99 | } |
| 100 | for _, c := range cols { |
| 101 | if _, ok := set[strings.TrimSpace(c)]; !ok { |
| 102 | return false |
| 103 | } |
| 104 | } |
| 105 | return true |
| 106 | } |
| 107 | |
| 108 | // Column returns the values of the column whose header matches name |
| 109 | // case-insensitively (trimming surrounding whitespace), with empty and |
no outgoing calls