From ba967d18a4806a07f8cda350550c57a06073c301 Mon Sep 17 00:00:00 2001 From: Dominic Smith Date: Tue, 2 Dec 2025 12:44:38 +1100 Subject: [PATCH 1/2] Skip unexported fields in schema --- lokerpc/schema.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lokerpc/schema.go b/lokerpc/schema.go index 6a80844..cc42ac2 100644 --- a/lokerpc/schema.go +++ b/lokerpc/schema.go @@ -54,6 +54,11 @@ func TypeSchema(t reflect.Type, tdefs map[reflect.Type]*NamedSchema) *jtd.Schema for i := 0; i < t.NumField(); i++ { f := t.Field(i) + + if !f.IsExported() { + continue + } + name, omit := parseTag(f.Tag.Get("json")) if name == "" { name = f.Name From 12d728a81e8aa062494135c7bbeeb7959a293891 Mon Sep 17 00:00:00 2001 From: Dominic Smith Date: Tue, 2 Dec 2025 12:51:14 +1100 Subject: [PATCH 2/2] Add test --- lokerpc/schema_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lokerpc/schema_test.go b/lokerpc/schema_test.go index 81b44df..02c5f78 100644 --- a/lokerpc/schema_test.go +++ b/lokerpc/schema_test.go @@ -24,7 +24,8 @@ func (textMarshaler) MarshalText() ([]byte, error) { func TestTypeSchema(t *testing.T) { type NamedStruct struct { - Foo string `json:"foo"` + Foo string `json:"foo"` + nope string } // Name to conflict with flag.Flag