ReadDir
Overview
ReadDir reads directory entries (fs.promises.readdir).
If you are coming from Node.js, the closest pattern is fs.readdir(path).
Signature
go
func ReadDir(ctx context.Context, path string) ([]os.DirEntry, error)Compare: Node.js · Standard Go · gox
js
fs.readdir(path)go
// os / io helpers — e.g. os.readdirgo
import "github.com/sahilkhaire/gox/fs"
fs.ReadDir(ctx, path)Example
go
import "github.com/sahilkhaire/gox/fs"
fs.ReadDir(ctx, path)Tips
Pass context.Context as the first argument so cancellation and deadlines propagate correctly.
Standard library alternative
Use os.ReadFile, os.WriteFile, etc. Pass context.Context manually for cancellation.