On Tue, 21 Apr 2020 02:22:37 -0700 (PDT) Rakesh K R <rakeshkr1...@gmail.com> wrote:
> In C, we used to typecast this array of uint8_t to predefined > structure. > This is very bad even for a C program, as soon as you dereference pointer to such structure it's an undefined behavior, and not portable even on LE architectures, definitely such dereference would lead to a runtime crash on arm cpus, ubuntu or docker wouldn't change anything, also, the c compiler might add padding to your structure, which can make such parser give the wrong answer even on architectures that allows unaligned addressing. (unless you're non-standard compiler extensions to avoid that) Thus, even on C, the correct and portable way to parse an uint8_t array is also going bytes one by one, i recommend you stick with the "encoding/binary" package, it will do the right thing. BR. —wagner -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/20200422050932.7733e469%40pampas.