https://github.com/hymkor/trash-go
The trash-go is the library for golang to move specified files to trashbox
https://github.com/hymkor/trash-go
freedesktop go golang trash trashcan windows
Last synced: 3 months ago
JSON representation
The trash-go is the library for golang to move specified files to trashbox
- Host: GitHub
- URL: https://github.com/hymkor/trash-go
- Owner: hymkor
- License: mit
- Created: 2023-11-05T17:44:40.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-01-26T15:12:53.000Z (over 1 year ago)
- Last Synced: 2025-01-19T09:16:52.064Z (3 months ago)
- Topics: freedesktop, go, golang, trash, trashcan, windows
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
trash-go
========The trash-go is the library for golang to move specified files to trashbox (recycle-bin/trash-can) of Microsoft Windows.
```go doc |
package trash // import "github.com/hymkor/trash-go"func Throw(filenames ...string) error
```in NON-Windows environments (experimental)
------------------------------------------`trash.Throw` moves files to "the home trash" of [the FreeDesktop.org Trash specification 1.0][fd1].
[fd1]: https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html
Sample
------[cmd/trash/main.go](cmd/trash/main.go)
```cmd/trash/main.go
package mainimport (
"fmt"
"os"
"path/filepath""github.com/hymkor/trash-go"
)func main() {
args := os.Args[1:]
if len(args) > 0 {
filenames := make([]string, 0, len(args))
for _, arg := range args {
if matches, err := filepath.Glob(arg); err != nil {
filenames = append(filenames, arg)
} else {
filenames = append(filenames, matches...)
}
}
err := trash.Throw(filenames...)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}
}
```See also
--------- [hymkor/trash-rs: Move file(s) to trash-box of Microsoft Windows](https://github.com/hymkor/trash-rs)
The Rust version executable that is installed by `scoop install trash` on [hymkor/bucket](https://github.com/hymkor/scoop-bucket)