From 96a3ecd52c7f1e4786c3b7089145cf2a562b001d Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Fri, 29 Nov 2024 13:17:13 +0100 Subject: [PATCH] use reflect.TypeFor instead of kludgy reflect.TypeOf TypeFor was introduced in go1.22, which we already require. --- main.go | 2 +- webapisrv/server.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index ec2b662..38b4d14 100644 --- a/main.go +++ b/main.go @@ -2856,7 +2856,7 @@ func cmdWebapi(c *cmd) { c.Usage() } - t := reflect.TypeOf((*webapi.Methods)(nil)).Elem() + t := reflect.TypeFor[webapi.Methods]() methods := map[string]reflect.Type{} var ml []string for i := 0; i < t.NumMethod(); i++ { diff --git a/webapisrv/server.go b/webapisrv/server.go index 448c433..84305da 100644 --- a/webapisrv/server.go +++ b/webapisrv/server.go @@ -199,7 +199,7 @@ var docsIndex []byte func init() { var methods []string - mt := reflect.TypeOf((*webapi.Methods)(nil)).Elem() + mt := reflect.TypeFor[webapi.Methods]() n := mt.NumMethod() for i := 0; i < n; i++ { methods = append(methods, mt.Method(i).Name)