code: func (vm *VirtualMachine) GetAllAccessibleDatastores(ctx context.Context) ([]*DatastoreInfo, error) {
  	host, err := vm.HostSystem(ctx)
  	if err != nil {
  		klog.Errorf("Failed to get host system for VM: %q. err: %+v", vm.InventoryPath, err)
  		return nil, err
  	}
  	var hostSystemMo mo.HostSystem
  	s := object.NewSearchIndex(vm.Client())
  	err = s.Properties(ctx, host.Reference(), []string{DatastoreProperty}, &hostSystemMo)
  	if err != nil {
  		klog.Errorf("Failed to retrieve datastores for host: %+v. err: %+v", host, err)
  		return nil, err
  	}
  	var dsRefList []types.ManagedObjectReference
  	dsRefList = append(dsRefList, hostSystemMo.Datastore...)
  
  	var dsMoList []mo.Datastore
  	pc := property.DefaultCollector(vm.Client())
  	properties := []string{DatastoreInfoProperty}
  	err = pc.Retrieve(ctx, dsRefList, properties, &dsMoList)
  	if err != nil {
  		klog.Errorf("Failed to get Datastore managed objects from datastore objects."+
  			" dsObjList: %+v, properties: %+v, err: %v", dsRefList, properties, err)
  		return nil, err
  	}
  	klog.V(9).Infof("Result dsMoList: %+v", dsMoList)
  	var dsObjList []*DatastoreInfo
  	for _, dsMo := range dsMoList {
  		dsObjList = append(dsObjList,
  			&DatastoreInfo{
  				&Datastore{object.NewDatastore(vm.Client(), dsMo.Reference()),
  					vm.Datacenter},
  				dsMo.Info.GetDatastoreInfo()})
  	}
  	return dsObjList, nil
  }
docs: // GetAllAccessibleDatastores gets the list of accessible Datastores for the given Virtual Machine