From 0d8c4383a080434cc710c62c29a1bdf30b4d4f99 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Tue, 22 Sep 2026 03:55:12 +1000 Subject: [PATCH] chore(controlplane): adopt go fix's rewrites in schema.go task fmt is not a formatter: it runs go fix to a fixpoint and then golangci-lint's formatters, so a package can be gofmt-clean and still go-fix-dirty. The merge train's full gate on 0c25a1fc caught exactly that and rewrote this file -- reflect.TypeFor[T]() in place of reflect.TypeOf(T(0)), the t.Fields() iterator, and maps.Copy over a manual key-by-key copy. Adopted verbatim; formatter output is law here. The remaining stages of that gate ran against this content, so it arrives verified rather than merely formatted. The author's scoped gate could not have caught it: gofumpt and golangci-lint fmt agree with the original text, and only go fix disagrees. --- internal/app/controlplane/schema.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/internal/app/controlplane/schema.go b/internal/app/controlplane/schema.go index 0be6a1240..d28e57815 100644 --- a/internal/app/controlplane/schema.go +++ b/internal/app/controlplane/schema.go @@ -2,6 +2,7 @@ package controlplane import ( "encoding/json" + "maps" "reflect" "strings" "time" @@ -16,9 +17,9 @@ import ( const bareObjectSchema = `{"type":"object"}` var ( - configDurationType = reflect.TypeOf(config.Duration(0)) - channelDurationType = reflect.TypeOf(channelDuration(0)) - timeType = reflect.TypeOf(time.Time{}) + configDurationType = reflect.TypeFor[config.Duration]() + channelDurationType = reflect.TypeFor[channelDuration]() + timeType = reflect.TypeFor[time.Time]() ) // schemaJSON renders the JSON Schema a resource descriptor advertises, derived @@ -90,8 +91,7 @@ func schemaOf(t reflect.Type) map[string]any { func objectSchemaOf(t reflect.Type) map[string]any { properties := map[string]any{} - for i := range t.NumField() { - field := t.Field(i) + for field := range t.Fields() { if field.Anonymous { // encoding/json promotes an embedded struct's fields into the // enclosing object, so the schema lists them there too. Dropping @@ -100,9 +100,7 @@ func objectSchemaOf(t reflect.Type) map[string]any { if !ok { continue } - for name, property := range embedded { - properties[name] = property - } + maps.Copy(properties, embedded) continue } if field.PkgPath != "" {