Fix and simplify fs.Reader

fakeDir.{Readdir,Readdirnames} weren't handling the case n == 0
correctly. fakeFileInfo.sys is always nil, so omit the field.
This commit is contained in:
greatroar 2020-03-02 21:33:39 +01:00
parent c504aa505c
commit 1557c58eef
1 changed files with 3 additions and 4 deletions

View File

@ -275,7 +275,7 @@ type fakeDir struct {
}
func (d fakeDir) Readdirnames(n int) ([]string, error) {
if n >= 0 {
if n > 0 {
return nil, errors.New("not implemented")
}
names := make([]string, 0, len(d.entries))
@ -287,7 +287,7 @@ func (d fakeDir) Readdirnames(n int) ([]string, error) {
}
func (d fakeDir) Readdir(n int) ([]os.FileInfo, error) {
if n >= 0 {
if n > 0 {
return nil, errors.New("not implemented")
}
return d.entries, nil
@ -299,7 +299,6 @@ type fakeFileInfo struct {
size int64
mode os.FileMode
modtime time.Time
sys interface{}
}
func (fi fakeFileInfo) Name() string {
@ -323,5 +322,5 @@ func (fi fakeFileInfo) IsDir() bool {
}
func (fi fakeFileInfo) Sys() interface{} {
return fi.sys
return nil
}