UpdateColumnNameMap updates the column name map, returning an error if any of the column names are duplicates.
()
| 125 | // UpdateColumnNameMap updates the column name map, returning an error |
| 126 | // if any of the column names are duplicates. |
| 127 | func (dt *Table) UpdateColumnNameMap() error { |
| 128 | nc := dt.NumColumns() |
| 129 | dt.ColumnNameMap = make(map[string]int, nc) |
| 130 | var errs []error |
| 131 | for i, nm := range dt.ColumnNames { |
| 132 | if _, has := dt.ColumnNameMap[nm]; has { |
| 133 | err := fmt.Errorf("table.Table duplicate column name: %s", nm) |
| 134 | slog.Warn(err.Error()) |
| 135 | errs = append(errs, err) |
| 136 | } else { |
| 137 | dt.ColumnNameMap[nm] = i |
| 138 | } |
| 139 | } |
| 140 | if len(errs) > 0 { |
| 141 | return errors.Join(errs...) |
| 142 | } |
| 143 | return nil |
| 144 | } |
| 145 | |
| 146 | // AddColumn adds a new column to the table, of given type and column name |
| 147 | // (which must be unique). The cells of this column hold a single scalar value: |
no test coverage detected