File: huff.go

package info (click to toggle)
golang-github-glycerine-go-unsnap-stream 0.0~git20210130.47dfef3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 164 kB
  • sloc: makefile: 5
file content (28 lines) | stat: -rw-r--r-- 458 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main

import (
	"fmt"
	"io"
	"os"

	"compress/flate"
)

func main() {

	if len(os.Args) > 1 && os.Args[1] == "--help" {
		fmt.Fprintf(os.Stderr, "huff: compress stdin with Huffman-only DEFLATE (RFC 1951) compression, write to stdout.\n")
		os.Exit(1)
	}

	deflated, err := flate.NewWriter(os.Stdout, flate.HuffmanOnly)
	if err != nil {
		panic(err)
	}
	defer deflated.Close()

	_, err = io.Copy(deflated, os.Stdin)
	if err != nil {
		panic(err)
	}
}