encoding - How to save bits to a file in Go -


i want serialise data in go , have write individual bits. (specifically huffman encoding). best way this? obvious way take 8 bits @ time , shift first 1 7 places left, 6 next 1 , on.

i wondering whether or not there more idiomatic way this, possibly function in standard library. i've had @ encoding/gob, not seem offer control wish, example writing slice of 4 booleans (which have thought corresponded bits) outputed 24 bytes. i'm guessing has numbers signify slice start, boolean next etc.

is there way this?

encoding/gob binary encoding go values. has nothing ever bit operations. it's main purpose provide performant solution transfering go datastructures on network connections etc (especially rpc package).

golang's internal representation of slices struct containing pointer array (of appropriate type), , 2 ints, 1 length (i.e. number of elements in slice) , capacity (i.e. ammount of memory allocated array.

i don't think there support in standard library want accomplish. think need write own implementation, suggested yourself.

maybe can put relevant code in separate package , share it, go young language , needs implemetions this, think.

sorry couldn't of more help.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -