From 183b82e323b4c05d7f462742fe6addafff0702bf Mon Sep 17 00:00:00 2001 From: Harry Stebbins Date: Tue, 3 Sep 2024 14:41:47 -0400 Subject: [PATCH] fix: return nil when HeaderTable.Get does not find anything --- datatable.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/datatable.go b/datatable.go index c96fb60..c590ec3 100644 --- a/datatable.go +++ b/datatable.go @@ -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).