lunixbochs / struc

Better binary packing for Go
MIT License
576 stars 45 forks source link

Pack int as 3 bytes? #86

Closed andig closed 6 months ago

andig commented 4 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 4 years ago

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

andig commented 4 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 4 years ago

Check the other issues for an example