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:
2 files changed
+3
-3
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user