diff options
| author | Shulhan <ms@kilabit.info> | 2024-03-06 03:06:54 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-03-06 03:06:54 +0700 |
| commit | 1e7cb99f42bcd41e98326bd9406d3cecfb2a4542 (patch) | |
| tree | 9981f1ebc98670f516939374012646314dda663f /lib/memfs | |
| parent | 16607dc13477ee53d95ee0295192643f6e726652 (diff) | |
| download | pakakeh.go-1e7cb99f42bcd41e98326bd9406d3cecfb2a4542.tar.xz | |
all: conform with linter gosec, ineffasign, and makezero
Some of warnings from those linter are false positives, so we just
annotated them.
Diffstat (limited to 'lib/memfs')
| -rw-r--r-- | lib/memfs/memfs_test.go | 13 | ||||
| -rw-r--r-- | lib/memfs/node.go | 7 |
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/memfs/memfs_test.go b/lib/memfs/memfs_test.go index e6dffb0a..3c0f3f5e 100644 --- a/lib/memfs/memfs_test.go +++ b/lib/memfs/memfs_test.go @@ -58,14 +58,16 @@ func TestMain(m *testing.M) { } func TestNew(t *testing.T) { - afile := filepath.Join(_testWD, "testdata/index.html") - - cases := []struct { + type testCase struct { desc string expErr string expMapKeys []string opts Options - }{{ + } + + var afile = filepath.Join(_testWD, `testdata/index.html`) + + var listCase = []testCase{{ desc: "With empty dir", expErr: "open : no such file or directory", }, { @@ -152,10 +154,11 @@ func TestNew(t *testing.T) { }} var ( + c testCase mfs *MemFS err error ) - for _, c := range cases { + for _, c = range listCase { t.Log(c.desc) mfs, err = New(&c.opts) diff --git a/lib/memfs/node.go b/lib/memfs/node.go index 34ed18a5..5ed87b02 100644 --- a/lib/memfs/node.go +++ b/lib/memfs/node.go @@ -262,9 +262,10 @@ func (node *Node) Readdir(count int) (fis []os.FileInfo, err error) { return nil, nil } if count <= 0 || count >= len(node.Childs) { - fis = make([]os.FileInfo, len(node.Childs)) - for x := 0; x < len(node.Childs); x++ { - fis[x] = node.Childs[x] + fis = make([]os.FileInfo, 0, len(node.Childs)) + var child *Node + for _, child = range node.Childs { + fis = append(fis, child) } node.off = 0 return fis, nil |
