I have this code snippet:
if (reflect.TypeOf(device).String() == "*types.VirtualDisk") {
disk := device.(types.VirtualDisk)
fmt.Printf("%v - %v
", "capacityInKB", disk.CapacityInKB)
}
to which I get:
impossible type assertion: types.VirtualDisk does not implement types.BaseVirtualDevice (GetVirtualDevice method has pointer receiver)
But If I modify it to
if (reflect.TypeOf(device).String() == "*types.VirtualDisk") {
//disk := device.(types.VirtualDisk)
fmt.Printf("%v - %v
", "capacityInKB", device)//disk.CapacityInKB)
}
It works and prints all the properties of the object. How am I suppose to convert this?