// Copyright 2020 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package fsimport ()// ReadDirFS is the interface implemented by a file system// that provides an optimized implementation of ReadDir.typeReadDirFSinterface {FS// ReadDir reads the named directory // and returns a list of directory entries sorted by filename.ReadDir(name string) ([]DirEntry, error)}// ReadDir reads the named directory// and returns a list of directory entries sorted by filename.//// If fs implements ReadDirFS, ReadDir calls fs.ReadDir.// Otherwise ReadDir calls fs.Open and uses ReadDir and Close// on the returned file.func ( FS, string) ([]DirEntry, error) {if , := .(ReadDirFS); {return .ReadDir() } , := .Open()if != nil {returnnil, }defer .Close() , := .(ReadDirFile)if ! {returnnil, &PathError{Op: "readdir", Path: , Err: errors.New("not implemented")} } , := .ReadDir(-1)sort.Slice(, func(, int) bool { return [].Name() < [].Name() })return , }