go 1.19 泛型

package main

import (
	"fmt"
	"reflect"
)

type p[T, T1 any] struct {
	A string
	B T
	C T1
}

func main() {
	var p1 p[string, struct {
		Name string
		Age  int
	}]
	var p2 p[string, int64]

	fmt.Println(reflect.TypeOf(p1))
	fmt.Println(reflect.TypeOf(p2))
}

你可能感兴趣的:(Go,泛型)