• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..07-Jul-2020-

internal/H07-Jul-2020-752514

lzma/H03-May-2022-4,6433,403

.gitignoreH A D07-Jul-2020239 2617

LICENSEH A D07-Jul-20201.4 KiB2721

README.mdH A D07-Jul-20201.9 KiB7456

TODO.mdH A D07-Jul-20209.7 KiB320217

bits.goH A D07-Jul-20201.6 KiB7555

crc.goH A D07-Jul-20201.4 KiB5531

format.goH A D07-Jul-202015.6 KiB729520

lzmafilter.goH A D07-Jul-20202.7 KiB11885

make-docsH A D07-Jul-2020160 63

reader.goH A D07-Jul-20208.6 KiB374298

writer.goH A D07-Jul-20208.5 KiB387301

README.md

1# Package xz
2
3This Go language package supports the reading and writing of xz
4compressed streams. It includes also a gxz command for compressing and
5decompressing data. The package is completely written in Go and doesn't
6have any dependency on any C code.
7
8The package is currently under development. There might be bugs and APIs
9are not considered stable. At this time the package cannot compete with
10the xz tool regarding compression speed and size. The algorithms there
11have been developed over a long time and are highly optimized. However
12there are a number of improvements planned and I'm very optimistic about
13parallel compression and decompression. Stay tuned!
14
15## Using the API
16
17The following example program shows how to use the API.
18
19```go
20package main
21
22import (
23    "bytes"
24    "io"
25    "log"
26    "os"
27
28    "github.com/ulikunitz/xz"
29)
30
31func main() {
32    const text = "The quick brown fox jumps over the lazy dog.\n"
33    var buf bytes.Buffer
34    // compress text
35    w, err := xz.NewWriter(&buf)
36    if err != nil {
37        log.Fatalf("xz.NewWriter error %s", err)
38    }
39    if _, err := io.WriteString(w, text); err != nil {
40        log.Fatalf("WriteString error %s", err)
41    }
42    if err := w.Close(); err != nil {
43        log.Fatalf("w.Close error %s", err)
44    }
45    // decompress buffer and write output to stdout
46    r, err := xz.NewReader(&buf)
47    if err != nil {
48        log.Fatalf("NewReader error %s", err)
49    }
50    if _, err = io.Copy(os.Stdout, r); err != nil {
51        log.Fatalf("io.Copy error %s", err)
52    }
53}
54```
55
56## Using the gxz compression tool
57
58The package includes a gxz command line utility for compression and
59decompression.
60
61Use following command for installation:
62
63    $ go get github.com/ulikunitz/xz/cmd/gxz
64
65To test it call the following command.
66
67    $ gxz bigfile
68
69After some time a much smaller file bigfile.xz will replace bigfile.
70To decompress it use the following command.
71
72    $ gxz -d bigfile.xz
73
74