Skip to content

teeworlds-go/huffman

Folders and files

NameName
Last commit message
Last commit date
Jul 3, 2024
Jul 3, 2024
Jul 2, 2024
Jul 3, 2024
Jul 6, 2024
Jul 3, 2024
Jul 3, 2024
Jul 3, 2024
Jul 3, 2024
Jul 3, 2024
Jul 6, 2024
Jul 3, 2024
Jul 3, 2024
Jul 2, 2024
Jul 3, 2024
Jul 6, 2024
Jul 3, 2024
Jul 3, 2024

Repository files navigation

huffman

Go Reference Go Report Card

Teeworlds huffman compression library.

Installation

// for latest tagged release
go get github.com/teeworlds-go/huffman/v2@latest

// for bleeding edge master branch version
go get github.com/teeworlds-go/huffman@master

Sample usage

package main

import (
	"fmt"

	"github.com/teeworlds-go/huffman/v2"
)

func main() {
	data, err := huffman.Compress([]byte("hello world"))
	if err != nil {
		panic(err)
	}
	// data: [174 149 19 92 9 87 194 22 177 86 220 218 34 56 185 18 156 168 184 1]
	fmt.Printf("data: %v\n", data)

	data, err = huffman.Decompress([]byte{174, 149, 19, 92, 9, 87, 194, 22, 177, 86, 220, 218, 34, 56, 185, 18, 156, 168, 184, 1})
	if err != nil {
		panic(err)
	}
	// data: hello world
	fmt.Printf("data: %v\n", string(data))
}