trash

package
v0.174.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package trash moves a file or folder to the operating system's Trash (the Recycle Bin on Windows), never deleting it.

It is the only way the Files tab removes anything (ADR-089): a mistake there is undone from the Trash with the system's own Put Back / Restore. So every platform moves the item with the system's own trash call or with the platform's published trash layout, and where neither can be done safely the call is refused with a reason — it never falls back to a permanent delete.

  • macOS: NSFileManager's trashItemAtURL, through purego (the binary is built without cgo), which handles other volumes and keeps Put Back.
  • Windows: SHFileOperationW with FOF_ALLOWUNDO, only on a fixed local drive and only for items small enough that the Recycle Bin keeps them (an item the bin cannot hold would be deleted outright).
  • Linux and the BSDs: the freedesktop.org Trash specification 1.0 home trash ($XDG_DATA_HOME/Trash, else ~/.local/share/Trash), by rename only, so an item on another file system is refused rather than copied and deleted.

Index

Constants

View Source
const MaxBytes = 1 << 30

MaxBytes is the most one call moves to the Recycle Bin on Windows: past it the bin may delete instead of keeping (its default size is a share of the drive), so the call is refused there. Other platforms do not cap.

Variables

View Source
var ErrUnavailable = errors.New("the Trash cannot take this item")

ErrUnavailable is a trash that cannot take this item here; its message says why and what to do instead.

Functions

func Move

func Move(path string) error

Move puts path — a file, a folder or a symlink (the link itself, never its target) — into the Trash. path must be absolute.

func Supported

func Supported() (bool, string)

Supported reports whether this platform has a trash Caprock can use, and when not, why (shown beside a disabled Delete).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL