lunixbochs / struc

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

remaining portion of struct to string #77

Closed atlantageek closed 5 years ago

atlantageek commented 5 years ago

I would like to request a new tag. Some protocols I work with want the user to take the remaining portion of a struct and assign it to the last string. Would it be possible to add that as a feature.

lunixbochs commented 5 years ago

Can you be more specific and provide an example?

atlantageek commented 5 years ago

I would like to be able to define something like this. type connectIdl struct { IndicatorID uint32 InitiatorPort uint16 Capabilities uint32 KeepAliveInterval uint32 VendorID string struc:"remaining" }

If the object being unpacked is 20 bytes long the VendorID would take up the last 6 bytes of the 20 byte object.

lunixbochs commented 5 years ago

Unpack uses an io.reader. There’s no such thing as the rest of the data.

atlantageek commented 5 years ago

Point taken. Thanks