Thanks rob,
that works, although I would have prefered a solution without unsafe. I
found a thread from a few years back where someone proposed adding
NativeEndian to encoding/binary which would always do the right thing.
Too bad that never got anywhere.
Chris
On Thu, Aug 24, 2017 at 08:40:12AM
Agree about hidden assumption, and may be alignment issues.
Last try:
https://play.golang.org/p/6e-i0AFZri
Jamil Djadala
On Thursday, August 24, 2017 at 1:40:52 AM UTC+3, Rob 'Commander' Pike
wrote:
>
> Apologies, typo. This is it: https://play.golang.org/p/9XWoCiUH2D
>
> On Thu, Aug 24, 2017
Apologies, typo. This is it: https://play.golang.org/p/9XWoCiUH2D
On Thu, Aug 24, 2017 at 8:39 AM, Rob Pike wrote:
> I believe there is no safe (that is, unsafe-free) way to discover the
> native byte order. In a sense, this is because depending on the native
> byte order is intrinsically unsafe.
I believe there is no safe (that is, unsafe-free) way to discover the
native byte order. In a sense, this is because depending on the native
byte order is intrinsically unsafe. It is by definition not portable.
It is a terrible design decision.
By the way, that program may work but it's not sound.
It use unsafe, but works even in playground:
https://play.golang.org/p/S1rw157M9C
On Wednesday, August 23, 2017 at 3:49:39 PM UTC+3, Christian von Kietzell
wrote:
>
> Hi,
>
> I've stumbled across a problem I don't know how to solve.
>
> I'm trying to read (from stdin) four bytes into a uint32