{"id":26197416,"url":"https://github.com/golift/xtractr","last_synced_at":"2026-03-08T21:01:48.969Z","repository":{"id":40580526,"uuid":"240884682","full_name":"golift/xtractr","owner":"golift","description":"Go Library for Queuing and Extracting Archives: Rar, Zip, 7zip, Gz, Tar, Tgz, Bz2, Tbz2","archived":false,"fork":false,"pushed_at":"2025-04-13T00:13:22.000Z","size":228,"stargazers_count":34,"open_issues_count":10,"forks_count":15,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-15T03:55:39.178Z","etag":null,"topics":["7zip","bz2","decompress","extracter","extraction","extraction-library","golang-library","golang-module","gzip","rar","rar-files","tar","zip","zip-files"],"latest_commit_sha":null,"homepage":"https://golift.io/discord","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/golift.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}},"created_at":"2020-02-16T12:07:50.000Z","updated_at":"2025-04-12T22:21:58.000Z","dependencies_parsed_at":"2024-02-08T08:21:51.861Z","dependency_job_id":"1d40a13e-43a5-4a53-8d60-359fff6a4648","html_url":"https://github.com/golift/xtractr","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Fxtractr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Fxtractr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Fxtractr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golift%2Fxtractr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/golift","download_url":"https://codeload.github.com/golift/xtractr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249003952,"owners_count":21196794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["7zip","bz2","decompress","extracter","extraction","extraction-library","golang-library","golang-module","gzip","rar","rar-files","tar","zip","zip-files"],"created_at":"2025-03-12T02:26:57.717Z","updated_at":"2026-03-08T21:01:48.959Z","avatar_url":"https://github.com/golift.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `xtractr`\n\nGo Library for Queuing and Extracting ZIP, RAR, GZ, BZ2, TAR,\nTGZ, TBZ2, 7Z, ISO ([and other](https://github.com/golift/xtractr/issues/44)) compressed archive files.\nCan also be used ad-hoc for direct decompression and extraction. See docs.\n\n-   [GoDoc](https://pkg.go.dev/golift.io/xtractr)\n-   Works on Linux, Windows, FreeBSD and macOS **without Cgo**.\n-   Supports 32 and 64 bit architectures.\n-   Decrypts RAR and 7-Zip archives with passwords.\n-   Extracts ISO images (ISO9660 and UDF volumes).\n-   Splits FLAC+CUE sheets into individual tracks.\n-   Detects non-UTF8 zip filenames automatically.\n\n# Interface\n\nThis library provides a queue, and a common interface to extract files.\nIt does not do the heavy lifting, and relies on these libraries to extract files:\n\n- [**RAR**: nwaples/rardecode](https://github.com/nwaples/rardecode)\n- [**7-Zip**: bodgit/sevenzip](https://github.com/bodgit/sevenzip)\n- [**ISO**: kdomanski/iso9660](https://github.com/kdomanski/iso9660)\n- [**UDF**: golift/udf](https://github.com/golift/udf)\n- [**FLAC**: mewkiz/flac](https://github.com/mewkiz/flac)\n- [**Brotli**: andybalholm/brotli](https://github.com/andybalholm/brotli)\n- [**LZ4**: pierrec/lz4](https://github.com/pierrec/lz4)\n- [**XZ**: therootcompany/xz](https://github.com/therootcompany/xz)\n- [**Zstandard**: klauspost/compress](https://github.com/klauspost/compress)\n- [**S2**: klauspost/compress](https://github.com/klauspost/compress)\n- [**Snappy**: klauspost/compress](https://github.com/klauspost/compress)\n- [**Zlib**: klauspost/compress](https://github.com/klauspost/compress)\n- [**LZW**: sshaman1101/dcompress](https://github.com/sshaman1101/dcompress)\n\n`Zip`, `Gzip`, `Tar` and `Bzip` are all handled by the standard Go library.\n\n# Examples\n\n## Example 1 - Queue\n\n```golang\npackage main\n\nimport (\n\t\"log\"\n\t\"os\"\n\t\"strings\"\n\n\t\"golift.io/xtractr\"\n)\n\n// Logger satisfies the xtractr.Logger interface.\ntype Logger struct {\n\txtractr *log.Logger\n\tdebug   *log.Logger\n\tinfo    *log.Logger\n}\n\n// Printf satisfies the xtractr.Logger interface.\nfunc (l *Logger) Printf(msg string, v ...interface{}) {\n\tl.xtractr.Printf(msg, v...)\n}\n\n// Debug satisfies the xtractr.Logger interface.\nfunc (l *Logger) Debugf(msg string, v ...interface{}) {\n\tl.debug.Printf(msg, v...)\n}\n\n// Infof printf an info line.\nfunc (l *Logger) Infof(msg string, v ...interface{}) {\n\tl.info.Printf(msg, v...)\n}\n\nfunc main() {\n\tlog := \u0026Logger{\n\t\txtractr: log.New(os.Stdout, \"[XTRACTR] \", 0),\n\t\tdebug:   log.New(os.Stdout, \"[DEBUG] \", 0),\n\t\tinfo:    log.New(os.Stdout, \"[INFO] \", 0),\n\t}\n\tq := xtractr.NewQueue(\u0026xtractr.Config{\n\t\tSuffix:   \"_xtractd\",\n\t\tLogger:   log,\n\t\tParallel: 1,\n\t\tFileMode: 0644, // ignored for tar files.\n\t\tDirMode:  0755,\n\t})\n\tdefer q.Stop() // Stop() waits until all extractions finish.\n\n\tresponse := make(chan *xtractr.Response)\n\t// This sends an item into the extraction queue (buffered channel).\n\tq.Extract(\u0026xtractr.Xtract{\n\t\tName:       \"my archive\",    // name is not import to this library.\n\t\tSearchPath: \"/tmp/archives\", // can also be a direct file.\n\t\tCBChannel:  response,        // queue responses are sent here.\n\t})\n\n\t// Queue always sends two responses. 1 on start and again when finished (error or not)\n\tresp := \u003c-response\n\tlog.Infof(\"Extraction started: %s\", strings.Join(resp.Archives, \", \"))\n\n\tresp = \u003c-response\n\tif resp.Error != nil {\n\t\t// There is possibly more data in the response that is useful even on error.\n\t\t// ie you may want to cleanup any partial extraction.\n\t\tlog.Printf(\"Error: %v\", resp.Error)\n\t}\n\n\tlog.Infof(\"Extracted Files:\\n - %s\", strings.Join(resp.NewFiles, \"\\n - \"))\n}\n```\n\n## Example 2 - Direct\n\nThis example shows `ExtractFile()` with a very simple `XFile`.\nYou can choose output path, as well as file and dir modes.\nFailing to provide `OutputDir` results in unexpected behavior.\n`ExtractFile()` attempts to identify the type of file. If you\nknow the file type you may call the direct method instead:\n\n - `ExtractZIP(*XFile)`\n - `ExtractRAR(*XFile)`\n - `ExtractTar(*XFile)`\n - `ExtractGzip(*XFile)`\n - `ExtractBzip(*XFile)`\n - `ExtractTarGzip(*XFile)`\n - `ExtractTarBzip(*XFile)`\n - `Extract7z(*XFile)`\n - `ExtractISO(*XFile)`\n - `SplitCueFlac(*XFile)`\n\n```golang\npackage main\n\nimport (\n\t\"log\"\n\t\"strings\"\n\n\t\"golift.io/xtractr\"\n)\n\nfunc main() {\n\tx := \u0026xtractr.XFile{\n\t\tFilePath:  \"/tmp/myfile.zip\",\n\t\tOutputDir: \"/tmp/myfile\", // do not forget this.\n\t}\n\n\t// size is how many bytes were written.\n\t// files may be nil, but will contain any files written (even with an error).\n\tsize, files, err := xtractr.ExtractFile(x)\n\tif err != nil || files == nil {\n\t\tlog.Fatal(size, files, err)\n\t}\n\n\tlog.Println(\"Bytes written:\", size, \"Files Extracted:\\n -\", strings.Join(files, \"\\n -\"))\n}\n```\n\nThis is what `XFile` looks like (today at least):\n```golang\n// XFile defines the data needed to extract an archive.\ntype XFile struct {\n\tFilePath  string      // Path to archive being extracted.\n\tOutputDir string      // Folder to extract archive into.\n\tFileMode  os.FileMode // Write files with this mode.\n\tDirMode   os.FileMode // Write folders with this mode.\n\tPassword  string      // (RAR/7z) Archive password. Blank for none.\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolift%2Fxtractr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgolift%2Fxtractr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolift%2Fxtractr/lists"}