On Sun, May 5, 2019, 06:33 Immueggpain S <immueggp...@gmail.com> wrote:

> Ah, my bad! What I meant was that binary.Read will pad when writing to the
> struct, unlike memcpy.
>

Oh, yes you're right of course.

If you want to serialize a C struct using Go, you're going to have to
mention every field on the Go side.

You could serialize/deserialize using a language independent format like
protobufs (there are many of these formats). Then you can serialize the
data from any language, and deserialize it in any other language.

On Sat, May 4, 2019 at 10:50 AM Matt Harden <matt.har...@gmail.com> wrote:
>
>> Why do you think binary.Read should handle padding for you? Based on the
>> documentation, it would be a bug if it did.
>>
>> On Tue, Apr 30, 2019 at 4:42 AM Immueggpain S <immueggp...@gmail.com>
>> wrote:
>>
>>> I guess I have no other choice then? BTW binary.Read shoud handle
>>> padding automatically.
>>>
>>> On Mon, Apr 22, 2019 at 10:53 AM Ian Lance Taylor <i...@golang.org>
>>> wrote:
>>>
>>>> On Sat, Apr 20, 2019 at 11:53 AM <immueggp...@gmail.com> wrote:
>>>> >
>>>> > binary.Read can't set unexported fields, right?
>>>> > But my structs are defined in C, and I can't make all C source code
>>>> using capital fields..
>>>> > What could I do?
>>>>
>>>> Read the fields separately.  That is often a better idea in any case,
>>>> as the result is more portable and avoids problems with structs that
>>>> require padding between fields.
>>>>
>>>> Ian
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to golang-nuts+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to