Package encoding/binary types Varint and Uvarint use the protobuf Varint 
wire format, which is little-endian. 

package encoding/binary       
https://pkg.go.dev/encoding/binary@latest        

Encoding: Explains how Protocol Buffers encodes data to files or to the 
wire.        
https://protobuf.dev/programming-guides/encoding/        

"These 7-bit payloads are in little-endian order."    


On Friday, October 3, 2025 at 11:01:30 AM UTC-4 R. Men wrote:

> Hello, I'm new to the language and I have a question about uvarint 
> decoding, hoping someone can clarify. Looking at the the source code, it 
> seems to assume that data is littleEndian and converts to bigEndian. What 
> if my data is already bigEndian? 
>
> Here's the current problem I'm trying to resolve
> buf{0x81, 0x47}  ----> 1000 0001 , 0100 0111
>
> I'm expecting      ---->  x000 0001 , x100 0111
>                               ---->  0000 0000 , 1100 0111 
>                               ----> 0xC7
> but instead I'm getting
>                               -----> x100 0111 , x000 0001
>                               -----> 0010 0011 , 1000 0001
>                               -----> 0x2381
> Is there a variant of uvarint that preserves the order or some solution to 
> this?
> Thank you for the help!
>

-- 
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/b96e6b54-2850-4b8f-ae39-7323a776c929n%40googlegroups.com.

Reply via email to