Skip to content
Node: fs.copyFile(src, dst)github.com/sahilkhaire/gox/fs

Copy

Overview

Copy copies src to dst (fs.promises.copyFile).

If you are coming from Node.js, the closest pattern is fs.copyFile(src, dst).

Signature

go
func Copy(ctx context.Context, src, dst string) error

Compare: Node.js · Standard Go · gox

js
fs.copyFile(src, dst)
go
// os / io helpers — e.g. os.copy
go
import "github.com/sahilkhaire/gox/fs"

fs.Copy(ctx, src, dst)

Example

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

fs.Copy(ctx, src, dst)

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