Skip to content
Node: fs.stat(path)github.com/sahilkhaire/gox/fs

Stat

Overview

Stat returns file info (fs.promises.stat).

If you are coming from Node.js, the closest pattern is fs.stat(path).

Signature

go
func Stat(ctx context.Context, path string) (os.FileInfo, error)

Compare: Node.js · Standard Go · gox

js
fs.stat(path)
go
// os / io helpers — e.g. os.stat
go
import "github.com/sahilkhaire/gox/fs"

fs.Stat(ctx, path)

Example

go
import "github.com/sahilkhaire/gox/fs"

fs.Stat(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.

Back to fs package overview

MIT Licensed · Built for Node.js developers moving to Go