reflect: add Type.String()

This commit is contained in:
Damian Gryski
2023-02-28 16:25:26 -08:00
committed by Damian Gryski
parent 7654d86d2c
commit 90af41d089
2 changed files with 52 additions and 1 deletions
+17
View File
@@ -221,6 +221,23 @@ func TestNamedTypes(t *testing.T) {
t.Errorf("TypeOf.Name()=%v, want %v", got, want)
}
if got, want := TypeOf(map[[4]uint16]string{}).String(), "map[[4]uint16]string"; got != want {
t.Errorf("Type.String()=%v, want %v", got, want)
}
s := struct {
a int8
b int8
c int8
d int8
e int8
f int32
}{}
if got, want := TypeOf(s).String(), "struct { a int8; b int8; c int8; d int8; e int8; f int32 }"; got != want {
t.Errorf("Type.String()=%v, want %v", got, want)
}
}
func equal[T comparable](a, b []T) bool {