Skip to content

Commit c8c4a4e

Browse files
committed
os:direntNamePtr for macos
1 parent f0728c4 commit c8c4a4e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

_demo/readdir/main.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
)
7+
8+
func main() {
9+
entries, err := os.ReadDir("../")
10+
if err != nil {
11+
panic(err)
12+
}
13+
if len(entries) == 0 {
14+
panic("No files found")
15+
}
16+
for _, e := range entries {
17+
fmt.Printf("%s isDir[%t]\n", e.Name(), e.IsDir())
18+
}
19+
}

runtime/internal/lib/os/dir.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ func direntNamePtr(name any) *byte {
120120
return name
121121
case []byte:
122122
return &name[0]
123+
case [1024]int8:
124+
return (*byte)(unsafe.Pointer(&name[0]))
123125
default:
124126
panic("invalid type")
125127
}

0 commit comments

Comments
 (0)