reflect: Use TypeFor instead of TypeOf

Added in Go 1.22

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski committed 2025-12-15 18:56:34 +01:00
1 parent 3df05205f4
commit bce14ac5bc
2 files changed
+3 -3

No files matched your search

+2 -2
View File
@@ -468,7 +468,7 @@ type overwriteTransformer struct {
}
func (tf overwriteTransformer) Transformer(typ reflect.Type) func(dst, src reflect.Value) error {
if typ == reflect.TypeOf(CommonConfig{}) {
if typ == reflect.TypeFor[CommonConfig]() {
return func(dst, src reflect.Value) error {
dst.FieldByName(tf.fieldName).Set(src.FieldByName(tf.fieldName))
return nil
@@ -702,7 +702,7 @@ func TestConfigInvalidDNS(t *testing.T) {
}
func field(field string) cmp.Option {
tmp := reflect.TypeOf(Config{})
tmp := reflect.TypeFor[Config]()
ignoreFields := make([]string, 0, tmp.NumField())
for i := 0; i < tmp.NumField(); i++ {
if tmp.Field(i).Name != field {
+1 -1
View File
@@ -16,7 +16,7 @@ import (
// TimeoutFlag is the flag to set a per-test timeout when running tests. Defaults to `-timeout`.
var TimeoutFlag = flag.Duration("timeout", 0, "DO NOT USE")
var typTestingT = reflect.TypeOf(new(testing.T))
var typTestingT = reflect.TypeFor[*testing.T]()
// Run takes a testing suite and runs all of the tests attached to it.
func Run(ctx context.Context, t *testing.T, suite any) {