reflect: add MakeMap()

This commit is contained in:
Damian Gryski
2023-02-25 14:48:58 -08:00
committed by Ayke
parent 828c3169ab
commit c4dadbaaab
2 changed files with 53 additions and 1 deletions
+8
View File
@@ -96,6 +96,14 @@ func TestMap(t *testing.T) {
t.Errorf("SetMapIndex(bar, 6) got %v, want %v", got, want)
}
m2ref := MakeMap(mref.Type())
m2ref.SetMapIndex(ValueOf("foo"), ValueOf(2))
m2 := m2ref.Interface().(map[string]int)
if m2["foo"] != 2 {
t.Errorf("MakeMap failed to create map")
}
}
func equal[T comparable](a, b []T) bool {