code: func (k *KVS) List(args *structs.KeyRequest, reply *structs.IndexedDirEntries) error {
  	if done, err := k.srv.forward("KVS.List", args, args, reply); done {
  		return err
  	}
  
  	aclToken, err := k.srv.ResolveToken(args.Token)
  	if err != nil {
  		return err
  	}
  
  	if aclToken != nil && k.srv.config.ACLEnableKeyListPolicy && !aclToken.KeyList(args.Key) {
  		return acl.ErrPermissionDenied
  	}
  
  	return k.srv.blockingQuery(
  		&args.QueryOptions,
  		&reply.QueryMeta,
  		func(ws memdb.WatchSet, state *state.Store) error {
  			index, ent, err := state.KVSList(ws, args.Key)
  			if err != nil {
  				return err
  			}
  			if aclToken != nil {
  				ent = FilterDirEnt(aclToken, ent)
  			}
  
  			if len(ent) == 0 {
  				// Must provide non-zero index to prevent blocking
  				// Index 1 is impossible anyways (due to Raft internals)
  				if index == 0 {
  					reply.Index = 1
  				} else {
  					reply.Index = index
  				}
  				reply.Entries = nil
  			} else {
  				reply.Index = index
  				reply.Entries = ent
  			}
  			return nil
  		})
  }
docs: // List is used to list all keys with a given prefix.