Huffman encoding library implemented in Go This does not include any type of Reader or Writer although it is planned.
This is a native implementation of the Huffman encoding algorithm in Go. To install it, you can use the go get
command:
go get github.com/newtoallofthis123/huffman
package main
func main(){
chars := []rune{'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'C', 'C', 'C', 'C', 'C', 'C', 'D', 'D', 'D', 'D', 'E', 'E'}
// This is needed since the library is implemented on generic slices
interfaces := huffman.ConvertToInterface(chars)
h := huffman.FromList(interfaces)
res := h.Encode()
r := h.Decode(res)
fmt.Println(r, res)
}
This project is licensed under the MIT License - see the LICENSE file for details