Code-Memo

Copy and move files (io + os)

Python’s shutil maps to os.Rename, io.Copy, and helpers like os.ReadFile/WriteFile.

Copy file to file
src, err := os.Open("in.txt")
if err != nil {
	return err
}
defer src.Close()

dst, err := os.Create("out.txt")
if err != nil {
	return err
}
defer dst.Close()

if _, err := io.Copy(dst, src); err != nil {
	return err
}
return dst.Sync()
Copy with metadata (best-effort)

There is no single stdlib call; copy bytes then os.Chtimes, os.Chmod as needed. For full fidelity across platforms, third-party packages exist.

Move / rename
err := os.Rename("a", "b")

Cross-device renames may fail — fall back to copy+delete.

Remove tree
err := os.RemoveAll("dir")
Disk usage

Walk with filepath.WalkDir (or fs.WalkDir) and sum os.DirEntry / FileInfo sizes.

Archive

archive/zip and archive/tar for packing, not shutil.make_archive one-liner — but straightforward.