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 value. Those > bytes are provided in _native_ byte order by an external program.[*1] > > Since I've found nothing in the standard library to determine the > machine's native byte order I can't decide whether to use > binary.BigEndian.Uint32 or binary.LittleEndian.Uint32. > > Is there a way without involving package unsafe? Am I missing something > obvious? > > [*1] The data comes from a web browser extension using the native > messaging API, which specifies that messages sent to external programs > are prefixed with the 32-bit length of the message in native byte order. > > > Thanks, > Chris > > -- > Nothing to see here. Move along. > -- 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.