Skip to content

Commit

Permalink
fix: return nil when HeaderTable.Get does not find a corresponding he…
Browse files Browse the repository at this point in the history
…ader (#36)
  • Loading branch information
harry-stebbins-dailypay committed Sep 3, 2024
1 parent ae1ad2e commit a4fc0d4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions datatable.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,14 @@ type HeaderTable struct {
}

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

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

0 comments on commit a4fc0d4

Please sign in to comment.