From 402fa11e293052b4d2b5792ef8062a228f0c2789 Mon Sep 17 00:00:00 2001 From: "Mason J. Katz" Date: Fri, 21 Aug 2026 18:05:37 -0700 Subject: [PATCH 1/2] fix: prevent Write nil panic Fixes #1 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- table.go | 3 ++- table_test.go | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/table.go b/table.go index 5f2861d..07ccb4c 100644 --- a/table.go +++ b/table.go @@ -115,7 +115,8 @@ func New(opts ...func(*Table)) *Table { // flushed if a new struct type is written. If a is not a struct, an error table // will be added to the output. func (t *Table) Write(a any) { - if reflect.TypeOf(a).Kind() != reflect.Struct { + typ := reflect.TypeOf(a) + if typ == nil || typ.Kind() != reflect.Struct { msg := struct { Error error Type string diff --git a/table_test.go b/table_test.go index 0568bf0..76a5ffe 100644 --- a/table_test.go +++ b/table_test.go @@ -254,6 +254,21 @@ func TestWriteNonStruct(t *testing.T) { } } +func TestWriteNil(t *testing.T) { + var buf bytes.Buffer + + tbl := New(WithWriter(&buf)) + + tbl.Write(nil) + _ = tbl.Flush() + + output := buf.String() + + if !strings.Contains(output, "not a struct") { + t.Errorf("expected error message in output, got: %q", output) + } +} + func TestEmptyTable(t *testing.T) { var buf bytes.Buffer From 32885a2cb0e8773d792458206371bf003f18a4f0 Mon Sep 17 00:00:00 2001 From: "Mason J. Katz" Date: Fri, 21 Aug 2026 18:24:31 -0700 Subject: [PATCH 2/2] ci: pin shared workflows to v1.3.1 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 99db0d5..3e8d465 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,7 +10,7 @@ on: jobs: lint: - uses: endobit/ci/.github/workflows/go-lint.yaml@main + uses: endobit/ci/.github/workflows/go-lint.yaml@v1.3.1 test: - uses: endobit/ci/.github/workflows/go-test.yaml@main + uses: endobit/ci/.github/workflows/go-test.yaml@v1.3.1 secrets: inherit