]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/ulikunitz/xz/README.md
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / ulikunitz / xz / README.md
CommitLineData
15c0b25d
AP
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
107c1cdb 15## Using the API
15c0b25d
AP
16
17The following example program shows how to use the API.
18
107c1cdb
ND
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)
15c0b25d 38 }
107c1cdb
ND
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```
15c0b25d 55
107c1cdb 56## Using the gxz compression tool
15c0b25d
AP
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