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

..03-May-2022-

cmd/H24-Feb-2020-

doc/H24-Feb-2020-

internal/H24-Feb-2020-

lzma/H03-May-2022-

.gitignoreH A D24-Feb-2020239

LICENSEH A D24-Feb-20201.4 KiB

README.mdH A D24-Feb-20201.9 KiB

TODO.mdH A D24-Feb-202010 KiB

bits.goH A D24-Feb-20201.6 KiB

bits_test.goH A D24-Feb-2020738

crc.goH A D24-Feb-20201.4 KiB

example.goH A D24-Feb-2020878

format.goH A D24-Feb-202015.7 KiB

format_test.goH A D24-Feb-20203.2 KiB

go.modH A D24-Feb-202040

lzmafilter.goH A D24-Feb-20202.7 KiB

make-docsH A D24-Feb-2020160

none-check.goH A D24-Feb-2020519

none-check_test.goH A D24-Feb-2020373

reader.goH A D24-Feb-20208.6 KiB

reader_test.goH A D24-Feb-20202.2 KiB

writer.goH A D24-Feb-20208.6 KiB

writer_test.goH A D24-Feb-20204 KiB

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