I believe the issue stems from the size calculation that is done for fields. The field kind is checked before the check for a custom type which means that the Custom.Size() method is never invoked and the code instead panics.
I have a tentative fix in my fork, I added a test case as well and looks to me like that has resolved the issue. I would be happy to open a PR if you will accept it. Let me know.
Attempting to invoke
struc.Pack
on a custom type of king string leads to a panic with message:"Cannot resolve size of type: <TYPE NAME>
.Minimal code to reproduce the issue below:
I believe the issue stems from the size calculation that is done for fields. The field kind is checked before the check for a custom type which means that the
Custom.Size()
method is never invoked and the code instead panics.