implements lstat and fixes inode stat on windows go 1.20 (#1168)

gojs: implements lstat

This implements platform.Lstat and uses it in GOOS=js. Notably,
directory listings need to run lstat on their entries to get the correct
inodes back. In GOOS=js, directories are a fan-out of names, then lstat.

This also fixes stat for inodes on directories. We were missing a test
so we didn't know it was broken on windows. The approach used now is
reliable on go 1.20, and we should suggest anyone using windows to
compile with go 1.20.

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
Crypt Keeper
2023-02-28 07:20:31 +08:00
committed by GitHub
parent d955cd7a13
commit 3d5b6d609a
18 changed files with 578 additions and 131 deletions

View File

@@ -45,6 +45,18 @@ func TestDirFS_String(t *testing.T) {
require.Equal(t, ".", testFS.String())
}
func TestDirFS_Lstat(t *testing.T) {
tmpDir := t.TempDir()
require.NoError(t, fstest.WriteTestFiles(tmpDir))
testFS := NewDirFS(tmpDir)
for _, path := range []string{"animals.txt", "sub", "sub-link"} {
require.NoError(t, testFS.Symlink(path, path+"-link"))
}
testLstat(t, testFS)
}
func TestDirFS_MkDir(t *testing.T) {
tmpDir := t.TempDir()
testFS := NewDirFS(tmpDir)