mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
all: use reflect.TypeFor now available in Go 1.22 (#11078)
Updates #cleanup Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
@@ -72,7 +72,7 @@ func (m NodeMutationLastSeen) Apply(n *tailcfg.Node) {
|
||||
|
||||
var peerChangeFields = sync.OnceValue(func() []reflect.StructField {
|
||||
var fields []reflect.StructField
|
||||
rt := reflect.TypeOf((*tailcfg.PeerChange)(nil)).Elem()
|
||||
rt := reflect.TypeFor[tailcfg.PeerChange]()
|
||||
for i := 0; i < rt.NumField(); i++ {
|
||||
fields = append(fields, rt.Field(i))
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ func TestMapResponseContainsNonPatchFields(t *testing.T) {
|
||||
case reflect.Bool:
|
||||
return reflect.ValueOf(true)
|
||||
case reflect.String:
|
||||
if reflect.TypeOf(opt.Bool("")) == t {
|
||||
if reflect.TypeFor[opt.Bool]() == t {
|
||||
return reflect.ValueOf("true").Convert(t)
|
||||
}
|
||||
return reflect.ValueOf("foo").Convert(t)
|
||||
@@ -43,7 +43,7 @@ func TestMapResponseContainsNonPatchFields(t *testing.T) {
|
||||
panic(fmt.Sprintf("unhandled %v", t))
|
||||
}
|
||||
|
||||
rt := reflect.TypeOf(tailcfg.MapResponse{})
|
||||
rt := reflect.TypeFor[tailcfg.MapResponse]()
|
||||
for i := 0; i < rt.NumField(); i++ {
|
||||
f := rt.Field(i)
|
||||
|
||||
|
Reference in New Issue
Block a user