我想知道是否有可能初始化匿名 struct 包含泛型字段的array.下面的代码无法编译,而且我找不到任何与以下内容相关的示例:
testCases := type [K comparable, T Numeric] []struct {
name string
args map[K]T
expected int
}{
// items ...
{"integer", map[string]int{ "a":1 },
}
没有匿名 struct ,这很容易,但目标不是:
type args[K comparable, T Numeric] struct {
m map[K]T
}
testCases := []struct {
name string
args args[string, int]
expected int
}{}
谢谢