From a5ea8ed367c5457ba0fd0285010dc95b74b47062 Mon Sep 17 00:00:00 2001 From: James Date: Sun, 18 Jun 2023 16:25:18 +0200 Subject: [PATCH] skip unexported fields to prevent panic --- sqlez.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sqlez.go b/sqlez.go index 2e6a1a8..0f97f54 100644 --- a/sqlez.go +++ b/sqlez.go @@ -87,6 +87,11 @@ func (s *DB) scanStruct(v reflect.Value, pointers bool, skipEmpty bool, firstRun _, skiptagexists := fieldt.Tag.Lookup(s.dbskipTag) skip := (skipEmpty && (field.Interface() == reflect.Zero(field.Type()).Interface())) + // Ignore all unexported or skipped fields + if (!jsonexists && !dbexists) || skiptagexists { + continue + } + if label == "" && dblabel != "" { label = dblabel }