3 This Go language package supports the reading and writing of xz
4 compressed streams. It includes also a gxz command for compressing and
5 decompressing data. The package is completely written in Go and doesn't
6 have any dependency on any C code.
8 The package is currently under development. There might be bugs and APIs
9 are not considered stable. At this time the package cannot compete with
10 the xz tool regarding compression speed and size. The algorithms there
11 have been developed over a long time and are highly optimized. However
12 there are a number of improvements planned and I'm very optimistic about
13 parallel compression and decompression. Stay tuned!
17 The following example program shows how to use the API.
28 "github.com/ulikunitz/xz"
32 const text = "The quick brown fox jumps over the lazy dog.\n"
35 w, err := xz.NewWriter(&buf)
37 log.Fatalf("xz.NewWriter error %s", err)
39 if _, err := io.WriteString(w, text); err != nil {
40 log.Fatalf("WriteString error %s", err)
42 if err := w.Close(); err != nil {
43 log.Fatalf("w.Close error %s", err)
45 // decompress buffer and write output to stdout
46 r, err := xz.NewReader(&buf)
48 log.Fatalf("NewReader error %s", err)
50 if _, err = io.Copy(os.Stdout, r); err != nil {
51 log.Fatalf("io.Copy error %s", err)
56 ## Using the gxz compression tool
58 The package includes a gxz command line utility for compression and
61 Use following command for installation:
63 $ go get github.com/ulikunitz/xz/cmd/gxz
65 To test it call the following command.
69 After some time a much smaller file bigfile.xz will replace bigfile.
70 To decompress it use the following command.