code: func (d Datastore) AttachedHosts(ctx context.Context) ([]*HostSystem, error) {
  	var ds mo.Datastore
  	var hosts []*HostSystem
  
  	pc := property.DefaultCollector(d.Client())
  	err := pc.RetrieveOne(ctx, d.Reference(), []string{"host"}, &ds)
  	if err != nil {
  		return nil, err
  	}
  
  	mounts := make(map[types.ManagedObjectReference]types.DatastoreHostMount)
  	var refs []types.ManagedObjectReference
  	for _, host := range ds.Host {
  		refs = append(refs, host.Key)
  		mounts[host.Key] = host
  	}
  
  	var hs []mo.HostSystem
  	err = pc.Retrieve(ctx, refs, []string{"runtime.connectionState", "runtime.powerState"}, &hs)
  	if err != nil {
  		return nil, err
  	}
  
  	for _, host := range hs {
  		if host.Runtime.ConnectionState == types.HostSystemConnectionStateConnected &&
  			host.Runtime.PowerState == types.HostSystemPowerStatePoweredOn {
  
  			mount := mounts[host.Reference()]
  			info := mount.MountInfo
  
  			if *info.Mounted && *info.Accessible && info.AccessMode == string(types.HostMountModeReadWrite) {
  				hosts = append(hosts, NewHostSystem(d.Client(), mount.Key))
  			}
  		}
  	}
  
  	return hosts, nil
  }
docs: // AttachedHosts returns hosts that have this Datastore attached, accessible and writable.