I am performing a type assertion (as my passed in type is map[string]interface{}. When I assign the value to a variable as such:
(*D).Memory = m["memory"].(int32)
I get the following panic:
panic: interface conversion: interface is int, not int32
goroutine 1 [running]:
runtime.panic(0x4a3c20, 0xc210047000)
/usr/lib/go/src/pkg/runtime/panic.c:266 +0xb6
test/device.(*Device).Init(0xc210046000, 0xc21001e390)
/home/user/Development/Go/src/test/device/device.go:112 +0x5fa
main.main()
/home/user/Development/Go/src/test/main.go:12 +0x201
exit status 2
If I change the value from int32 to int64 I get the same, but when I change the values to int along it all works fine. Given, I have to change the corresponding struct to int64's and int's as well, that is done.
I have been told this is not a bug, understanding why it isn't, would be nice. Thanks
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I am performing a type assertion (as my passed in type is map[string]interface{}. When I assign the value to a variable as such:
(*D).Memory = m["memory"].(int32)
I get the following panic:
panic: interface conversion: interface is int, not int32
If I change the value from int32 to int64 I get the same, but when I change the values to int along it all works fine. Given, I have to change the corresponding struct to int64's and int's as well, that is done.
I have been told this is not a bug, understanding why it isn't, would be nice. Thanks