{"id":18053895,"url":"https://github.com/hymkor/trash-go","last_synced_at":"2026-03-09T10:01:30.585Z","repository":{"id":205644611,"uuid":"714728625","full_name":"hymkor/trash-go","owner":"hymkor","description":"The trash-go is the library for golang to move specified files to trashbox","archived":false,"fork":false,"pushed_at":"2025-05-31T13:31:08.000Z","size":27,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-22T12:41:58.280Z","etag":null,"topics":["freedesktop","go","golang","trash","trashcan","windows"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/hymkor/trash-go","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hymkor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-05T17:44:40.000Z","updated_at":"2025-07-02T15:10:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"1c0cc77e-0d40-421e-bd15-875b9e79f99f","html_url":"https://github.com/hymkor/trash-go","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"ba5d99c98e420b4aace7c91b7e14425f368b4616"},"previous_names":["hymkor/trash-go"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/hymkor/trash-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Ftrash-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Ftrash-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Ftrash-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Ftrash-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hymkor","download_url":"https://codeload.github.com/hymkor/trash-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hymkor%2Ftrash-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30290899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["freedesktop","go","golang","trash","trashcan","windows"],"created_at":"2024-10-31T00:08:28.770Z","updated_at":"2026-03-09T10:01:30.559Z","avatar_url":"https://github.com/hymkor.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"trash-go\r\n========\r\n\r\n[![Go Reference](https://pkg.go.dev/badge/github.com/hymkor/trash-go.svg)](https://pkg.go.dev/github.com/hymkor/trash-go)\r\n\r\n**trash-go** is a Go library and command-line tool for moving specified files to the trash (Recycle Bin on Windows, Trash Can on Linux desktop environments).\r\n\r\n- ✅ **Windows**: Uses the `SHFileOperationW` API in `Shell32.dll`.\r\n- ⚠️ **Non-Windows** (experimental): Follows the [FreeDesktop.org Trash Specification 1.0][fd1] to move files to the user's \"home trash\".\r\n\r\n[fd1]: https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html\r\n\r\nInstallation\r\n------------\r\n\r\n### As a Library\r\n\r\n```bash\r\ngo get github.com/hymkor/trash-go\r\n```\r\n\r\n### As a Command-Line Tool\r\n\r\n```bash\r\ngo install github.com/hymkor/trash-go/cmd/trash@latest\r\n```\r\n\r\nThis will install a `trash` executable in your `$GOBIN` directory.\r\n\r\nUsage\r\n-----\r\n\r\n### Library\r\n\r\n```go\r\npackage trash // import \"github.com/hymkor/trash-go\"\r\n\r\nfunc Throw(filenames ...string) error\r\n```\r\n\r\n`Throw` accepts one or more file paths and moves them to the trash.\r\n\r\n### Command-Line Tool\r\n\r\n```bash\r\ntrash [OPTIONS] FILE...\r\n```\r\n\r\nMoves the specified files to the trash.\r\n\r\n#### Options\r\n\r\n* `-from-file FILENAME`\r\n  Read a list of files (one per line) from the given file instead of command-line arguments.\r\n  Use `-` as the filename to read from standard input.\r\n\r\n#### Examples\r\n\r\n```bash\r\ntrash *.log                 # Move matching files to trash\r\ntrash -from-file list.txt   # Move files listed in list.txt\r\nfind . -name \"*.tmp\" | trash -from-file -  # Use with standard input\r\n```\r\n\r\nExample (as library)\r\n--------------------\r\n\r\nSee [example.go](./example.go) for a complete usage example.\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n    \"fmt\"\r\n    \"os\"\r\n    \"path/filepath\"\r\n\r\n    \"github.com/hymkor/trash-go\"\r\n)\r\n\r\nfunc mains(args []string) error {\r\n    var filenames []string\r\n    for _, arg := range args {\r\n        if matches, err := filepath.Glob(arg); err != nil {\r\n            filenames = append(filenames, arg)\r\n        } else if len(matches) == 0 {\r\n            return fmt.Errorf(\"%s: %w\", arg, os.ErrNotExist)\r\n        } else {\r\n            filenames = append(filenames, matches...)\r\n        }\r\n    }\r\n    return trash.Throw(filenames...)\r\n}\r\n\r\nfunc main() {\r\n    if err := mains(os.Args[1:]); err != nil {\r\n        fmt.Fprintln(os.Stderr, err)\r\n        os.Exit(1)\r\n    }\r\n}\r\n```\r\n\r\nNotes\r\n-----\r\n\r\n- On **Windows**, files are moved to the Recycle Bin using native shell operations.\r\n- On **Linux**, the implementation creates `.Trash` or `.local/share/Trash` directories if they don't exist, following the FreeDesktop specification.\r\n\r\nSee also\r\n--------\r\n\r\n* [hymkor/trash-rs](https://github.com/hymkor/trash-rs)\r\n  A Rust implementation with similar functionality. Available via:\r\n  `scoop install trash` from [hymkor/scoop-bucket](https://github.com/hymkor/scoop-bucket)\r\n\r\nAuthor\r\n------\r\n\r\n[hymkor (HAYAMA Kaoru)](https://github.com/hymkor)\r\n\r\nLicense\r\n-------\r\n\r\nMIT License\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhymkor%2Ftrash-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhymkor%2Ftrash-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhymkor%2Ftrash-go/lists"}