Be able to print maps to some degree

Print the number of elements, or nil if it is a nil map.
This commit is contained in:
Ayke van Laethem
2018-08-30 02:26:48 +02:00
parent d930a9ba16
commit 42711c11e9
2 changed files with 16 additions and 0 deletions
+14
View File
@@ -102,7 +102,21 @@ func printitf(msg interface{}) {
}
}
func printmap(m *hashmap) {
print("map[")
if m == nil {
print("nil")
} else {
print(m.count)
}
putchar(']')
}
func printptr(ptr uintptr) {
if ptr == 0 {
print("nil")
return
}
putchar('0')
putchar('x')
for i := 0; i < int(unsafe.Sizeof(ptr))*2; i++ {