code: func ListInstances(c context.Context, pkg string, pageSize int32, cursor datastore.Cursor) (out []*Instance, nextCur datastore.Cursor, err error) {
  	if pageSize <= 0 {
  		panic("pageSize must be positive")
  	}
  
  	q := datastore.NewQuery("PackageInstance").
  		Ancestor(PackageKey(c, pkg)).
  		Order("-registered_ts").
  		Limit(pageSize)
  	if cursor != nil {
  		q = q.Start(cursor)
  	}
  
  	err = datastore.Run(c, q, func(ent *Instance, cb datastore.CursorCB) error {
  		out = append(out, ent)
  		if len(out) >= int(pageSize) {
  			if nextCur, err = cb(); err != nil {
  				return err
  			}
  			return datastore.Stop
  		}
  		return nil
  	})
  	if err != nil {
  		return nil, nil, transient.Tag.Apply(err)
  	}
  	return
  }
docs: // ListInstances lists instances of a package, more recent first.
  //
  // Only does a query over Instances entities. Doesn't check whether the Package
  // entity exists. Returns up to pageSize entities, plus non-nil cursor (if
  // there are more results). pageSize must be positive.