Skip to content

Commit a4fc0d4

Browse files
fix: return nil when HeaderTable.Get does not find a corresponding header (#36)
1 parent ae1ad2e commit a4fc0d4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

datatable.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,14 @@ type HeaderTable struct {
9191
}
9292

9393
// Get returns the cell at the provided row offset (skipping the header row)
94-
// and column name (as indicated in the header).
94+
// and column name (as indicated in the header). If the column name is not
95+
// found, nil is returned.
9596
func (h *HeaderTable) Get(row int, col string) *Cell {
96-
return h.DataTable.Cell(row+1, h.headers[col])
97+
if v, ok := h.headers[col]; !ok {
98+
return nil
99+
} else {
100+
return h.DataTable.Cell(row+1, v)
101+
}
97102
}
98103

99104
// NumRows returns the number of rows in the table (excluding the header row).

0 commit comments

Comments
 (0)