xz
xz copied to clipboard
How do you decompress tar.xz files?
Trying to discover how to extract tar.xz files. Is this possible?
First, decompress the *.tar.xz to a *.tar, either to memory or a temporary file. Then use a tar decompressor (i.e., import "archive/tar") on that.
A working xz decompressor is needed first; and this seems to be alpha software currently.
Many thanks for the interest in my code. The code is not even alpha right now. Currently the software contains working code for the LZMA method. This is the core compression method used by xz file format. But actually xz is using LZMA2 that contains chunks of LZMA compressed data. So I'm working currently on LZMA2.
When the code will be complete, I will provide examples on how to create and decompress tar files in Go.
Easy: https://github.com/mholt/archiver/blob/cdc68dd1f170b8dfc1a0d2231b5bb0967ed67006/tarxz.go#L53-L66
(Opening the .tar file is the "hard" part, but the xz decompression just gets layered on underneath it as you can see.)