mercredi 10 octobre 2018

Reflect showing different a different type than error

Background: Im using govmomi for configuration collection for vmware. I'm currently in the process of getting the datastore info I require. One of the fields I need is the disk Naa. This can be found in the VmfsDatastoreInfo struct under the Vmfs field.

Issue: I am looping through a range and I believed Ds.Info to be of the VmfsDatastoreInfo type so in theory I could get the info I needed by going through Ds.Info.Vmfs. When I reference this I get the error:

ds.Info.Vmfs undefined (type types.BaseDatastoreInfo has no field or method Vmfs)

Out of curiosity I explored using reflection and did the following:

fmt.Println(reflect.TypeOf(ds.Info))

output was

*types.VmfsDatastoreInfo

Im trying to understand why the same object is showing as two different types?

Govmomi Struct Info





Aucun commentaire:

Enregistrer un commentaire