filterHeaders filters the headers to only include the columns that are provided in the array. If the array is empty, all headers are included.
(header table.Row, columns []string)
| 35 | // that are provided in the array. If the array is empty, all |
| 36 | // headers are included. |
| 37 | func filterHeaders(header table.Row, columns []string) table.Row { |
| 38 | if len(columns) == 0 { |
| 39 | return header |
| 40 | } |
| 41 | |
| 42 | filteredHeaders := make(table.Row, len(columns)) |
| 43 | for i, column := range columns { |
| 44 | column = strings.ReplaceAll(column, "_", " ") |
| 45 | |
| 46 | for _, headerTextRaw := range header { |
| 47 | headerText, _ := headerTextRaw.(string) |
| 48 | if strings.EqualFold(column, headerText) { |
| 49 | filteredHeaders[i] = headerText |
| 50 | break |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | return filteredHeaders |
| 55 | } |
| 56 | |
| 57 | // createColumnConfigs returns configuration to hide columns |
| 58 | // that are not provided in the array. If the array is empty, |