lunixbochs / struc

Better binary packing for Go
MIT License
564 stars 42 forks source link

Pack int as 3 bytes? #86

Closed andig closed 4 months ago

andig commented 3 years ago

I need to pack an int as 3 bytes which panics:

Password int `struc:"[3]byte"`

Decoding seems possible, same when using pad instead of byte. Is this a supported operation?

lunixbochs commented 3 years ago

You’ll need to make a custom type describing how to pack it

andig commented 3 years ago

Great, thank you- wasn‘t even aware that a Packer interface existed. An example would be great, but I think the hint will do ;)

lunixbochs commented 3 years ago

Check the other issues for an example